mirror of
https://github.com/SapphireServer/Sapphire.git
synced 2025-04-28 07:07:45 +00:00
#48 - Fixed bnpcs not despawning properly, aswell as not updating cell as they go
This commit is contained in:
parent
839cca0d25
commit
c5882e0ed9
3 changed files with 10 additions and 3 deletions
|
@ -260,6 +260,7 @@ bool Sapphire::Entity::BNpc::moveTo( const FFXIVARR_POSITION3& pos )
|
|||
|
||||
|
||||
step();
|
||||
m_pCurrentZone->updateActorPosition( *this );
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
|
@ -240,8 +240,6 @@ bool Sapphire::Entity::Chara::face( const Common::FFXIVARR_POSITION3& p )
|
|||
float rot = Util::calcAngFrom( getPos().x, getPos().z, p.x, p.z );
|
||||
float newRot = PI - rot + ( PI / 2 );
|
||||
|
||||
m_pCell = nullptr;
|
||||
|
||||
setRot( newRot );
|
||||
|
||||
return oldRot != newRot;
|
||||
|
|
|
@ -408,6 +408,9 @@ void Sapphire::Zone::updateBNpcs( int64_t tickCount )
|
|||
}
|
||||
}
|
||||
|
||||
// Update loop may move actors from cell to cell, breaking iterator validity
|
||||
std::vector< Entity::BNpcPtr > m_activeBNpc;
|
||||
|
||||
for( uint32_t y = 0; y < _sizeY; ++y )
|
||||
{
|
||||
for( uint32_t x = 0; x < _sizeX; ++x )
|
||||
|
@ -426,10 +429,15 @@ void Sapphire::Zone::updateBNpcs( int64_t tickCount )
|
|||
for( const auto& actor : cell->m_actors )
|
||||
{
|
||||
if( actor->isBattleNpc() )
|
||||
actor->getAsBNpc()->update( tickCount );
|
||||
m_activeBNpc.push_back( actor->getAsBNpc() );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// iterate the cached active bnpcs
|
||||
for( const auto& actor : m_activeBNpc )
|
||||
actor->update( tickCount );
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue