mirror of
https://github.com/SapphireServer/Sapphire.git
synced 2025-04-24 05:37:45 +00:00
Fixed an issue where players were removed from the wrong zone
This commit is contained in:
parent
a0bf531315
commit
c92ee8b7cd
2 changed files with 15 additions and 13 deletions
|
@ -107,17 +107,13 @@ void Core::InstanceContent::onUpdate( uint32_t currTime )
|
|||
if( m_boundPlayerIds.size() == 0 )
|
||||
return;
|
||||
|
||||
for( const auto playerId : m_boundPlayerIds )
|
||||
for( auto playerId : m_boundPlayerIds )
|
||||
{
|
||||
auto it = m_playerMap.find( playerId );
|
||||
if( it == m_playerMap.end() )
|
||||
return;
|
||||
}
|
||||
|
||||
for( const auto& playerIt : m_playerMap )
|
||||
{
|
||||
const auto& player = playerIt.second;
|
||||
|
||||
auto player = it->second;
|
||||
if( !player->isLoadingComplete() ||
|
||||
!player->isDirectorInitialized() ||
|
||||
!player->isOnEnterEventDone() ||
|
||||
|
|
|
@ -226,19 +226,21 @@ void Core::Zone::pushActor( Entity::ActorPtr pActor )
|
|||
void Core::Zone::removeActor( Entity::ActorPtr pActor )
|
||||
{
|
||||
|
||||
auto pCell = pActor->getCellPtr();
|
||||
if( pCell )
|
||||
{
|
||||
pCell->removeActor( pActor );
|
||||
pCell = nullptr;
|
||||
}
|
||||
/* TODO: have to wait and see if removal of this actually breaks anything
|
||||
this however is potentially removing a player from a zone he does not belong to */
|
||||
//auto pCell = pActor->getCellPtr();
|
||||
//if( pCell )
|
||||
//{
|
||||
// pCell->removeActor( pActor );
|
||||
// pCell = nullptr;
|
||||
//}
|
||||
|
||||
if( pActor->isPlayer() )
|
||||
{
|
||||
|
||||
// If it's a player and he's inside boundaries - update his nearby cells
|
||||
if( pActor->getPos().x <= _maxX && pActor->getPos().x >= _minX &&
|
||||
pActor->getPos().z <= _maxY && pActor->getPos().z >= _minY )
|
||||
pActor->getPos().z <= _maxY && pActor->getPos().z >= _minY )
|
||||
{
|
||||
uint32_t x = getPosX( pActor->getPos().x );
|
||||
uint32_t y = getPosY( pActor->getPos().z );
|
||||
|
@ -539,7 +541,11 @@ void Core::Zone::updateActorPosition( Entity::Actor &actor )
|
|||
{
|
||||
|
||||
if( pOldCell )
|
||||
{
|
||||
auto pLog = g_fw.get< Logger >();
|
||||
pLog->debug( std::string( __FUNCTION__ ) + "removeActor" );
|
||||
pOldCell->removeActor( actor.shared_from_this() );
|
||||
}
|
||||
|
||||
pCell->addActor( actor.shared_from_this() );
|
||||
actor.setCell( pCell );
|
||||
|
|
Loading…
Add table
Reference in a new issue