1
Fork 0
mirror of https://github.com/SapphireServer/Sapphire.git synced 2025-05-03 09:17:47 +00:00

Merge pull request #926 from collett8192/Sapphire5.58_action

Port cell update from master
This commit is contained in:
Mordred 2023-03-19 07:43:01 +01:00 committed by GitHub
commit f4f977f0d8
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 22 additions and 4 deletions

View file

@ -511,7 +511,7 @@ void Sapphire::Entity::BNpc::doDefaultBNpcUpdate( uint64_t tickCount )
auto pHatedActor = hateListGetHighest(); auto pHatedActor = hateListGetHighest();
while( pHatedActor && !pHatedActor->isAlive() ) while( pHatedActor && ( !pHatedActor->isAlive() || getCurrentTerritory()->getGuId() != pHatedActor->getCurrentTerritory()->getGuId() ) )
{ {
hateListRemove( pHatedActor ); hateListRemove( pHatedActor );
pHatedActor = hateListGetHighest(); pHatedActor = hateListGetHighest();

View file

@ -1871,6 +1871,10 @@ void Sapphire::Entity::Player::sendZonePackets()
sendInventory(); sendInventory();
setTargetId( INVALID_GAME_OBJECT_ID64 );
setStance( Common::Stance::Passive );
setAutoattack( false );
if( isLogin() ) if( isLogin() )
{ {
queuePacket( makeActorControlSelf( getId(), SetCharaGearParamUI, m_equipDisplayFlags, 1 ) ); queuePacket( makeActorControlSelf( getId(), SetCharaGearParamUI, m_equipDisplayFlags, 1 ) );

View file

@ -102,3 +102,12 @@ void Sapphire::Cell::unload()
removeActors(); removeActors();
} }
uint32_t Sapphire::Cell::getLastActiveTime() const
{
return m_lastActiveTime;
}
void Sapphire::Cell::setLastActiveTime( uint32_t lastActiveTime )
{
m_lastActiveTime = lastActiveTime;
}

View file

@ -23,6 +23,7 @@ private:
bool m_bActive; bool m_bActive;
uint16_t m_playerCount; uint16_t m_playerCount;
uint32_t m_lastActiveTime;
public: public:
Cell(); Cell();
@ -85,6 +86,9 @@ public:
{ {
return m_posY; return m_posY;
} }
uint32_t getLastActiveTime() const;
void setLastActiveTime( uint32_t lastActiveTime );
}; };
} }

View file

@ -539,6 +539,7 @@ bool Sapphire::Territory::isCellActive( uint32_t x, uint32_t y )
uint32_t posY; uint32_t posY;
Cell* pCell; Cell* pCell;
uint32_t time = Common::Util::getTimeSeconds();
for( posX = startX; posX <= endX; posX++ ) for( posX = startX; posX <= endX; posX++ )
{ {
@ -546,7 +547,7 @@ bool Sapphire::Territory::isCellActive( uint32_t x, uint32_t y )
{ {
pCell = getCellPtr( posX, posY ); pCell = getCellPtr( posX, posY );
if( pCell && ( pCell->hasPlayers() || pCell->isForcedActive() ) ) if( pCell && ( pCell->hasPlayers() || pCell->isForcedActive() || ( time - pCell->getLastActiveTime() ) < 20 ) )
return true; return true;
} }
} }
@ -577,13 +578,13 @@ void Sapphire::Territory::updateCellActivity( uint32_t x, uint32_t y, int32_t ra
{ {
pCell = create( posX, posY ); pCell = create( posX, posY );
pCell->init( posX, posY ); pCell->init( posX, posY );
pCell->setActivity( true ); pCell->setActivity( true );
pCell->setLastActiveTime( Common::Util::getTimeSeconds() );
} }
} }
else else
{ {
pCell->setLastActiveTime( Common::Util::getTimeSeconds() );
//Cell is now active //Cell is now active
if( isCellActive( posX, posY ) && !pCell->isActive() ) if( isCellActive( posX, posY ) && !pCell->isActive() )
{ {