1
Fork 0
mirror of https://github.com/SapphireServer/Sapphire.git synced 2025-04-27 14:57:44 +00:00

refactoring of session update loop in zone

This commit is contained in:
Mordred 2018-02-14 20:44:35 +01:00
parent b95d741cd8
commit e8ab570502
2 changed files with 18 additions and 12 deletions

View file

@ -481,8 +481,18 @@ bool Core::Zone::update( uint32_t currTime )
{ {
int64_t tickCount = Util::getTimeMs(); int64_t tickCount = Util::getTimeMs();
//TODO: this should be moved to a updateWeather call and pulled out of updateSessions
bool changedWeather = checkWeather(); bool changedWeather = checkWeather();
updateSessions( changedWeather );
updateBnpcs( tickCount );
onUpdate( currTime );
return true;
}
void Core::Zone::updateSessions( bool changedWeather )
{
auto it = m_sessionSet.begin(); auto it = m_sessionSet.begin();
// update sessions in this zone // update sessions in this zone
@ -493,24 +503,24 @@ bool Core::Zone::update( uint32_t currTime )
if( !pSession ) if( !pSession )
{ {
it = m_sessionSet.erase( it ); it = m_sessionSet.erase(it );
continue; continue;
} }
// this session is not linked to this area anymore, remove it from zone session list // this session is not linked to this area anymore, remove it from zone session list
if( ( !pSession->getPlayer()->getCurrentZone() ) if( ( !pSession->getPlayer()->getCurrentZone() ) ||
|| ( pSession->getPlayer()->getCurrentZone() != shared_from_this() ) ) ( pSession->getPlayer()->getCurrentZone() != shared_from_this() ) )
{ {
if( pSession->getPlayer()->getCell() ) if( pSession->getPlayer()->getCell() )
removeActor( pSession->getPlayer() ); removeActor(pSession->getPlayer() );
it = m_sessionSet.erase( it ); it = m_sessionSet.erase(it );
continue; continue;
} }
if( changedWeather ) if( changedWeather )
{ {
Network::Packets::ZoneChannelPacket< Network::Packets::Server::FFXIVIpcWeatherChange > Core::Network::Packets::ZoneChannelPacket< Core::Network::Packets::Server::FFXIVIpcWeatherChange >
weatherChangePacket( pSession->getPlayer()->getId() ); weatherChangePacket( pSession->getPlayer()->getId() );
weatherChangePacket.data().weatherId = m_currentWeather; weatherChangePacket.data().weatherId = m_currentWeather;
weatherChangePacket.data().delay = 5.0f; weatherChangePacket.data().delay = 5.0f;
@ -521,12 +531,6 @@ bool Core::Zone::update( uint32_t currTime )
pSession->update(); pSession->update();
++it; ++it;
} }
updateBnpcs( tickCount );
onUpdate( currTime );
return true;
} }
bool Core::Zone::isCellActive( uint32_t x, uint32_t y ) bool Core::Zone::isCellActive( uint32_t x, uint32_t y )

View file

@ -111,6 +111,8 @@ public:
bool update( uint32_t currTime ); bool update( uint32_t currTime );
void updateSessions( bool changedWeather );
void registerInstanceObj( Entity::InstanceObjectPtr object ); void registerInstanceObj( Entity::InstanceObjectPtr object );
Entity::InstanceObjectPtr getInstanceObject( uint32_t objId ); Entity::InstanceObjectPtr getInstanceObject( uint32_t objId );
void updateInstanceObj( Entity::InstanceObjectPtr object ); void updateInstanceObj( Entity::InstanceObjectPtr object );