mirror of
https://github.com/SapphireServer/Sapphire.git
synced 2025-04-28 15:17:46 +00:00
only run bnpc update in active cells
This commit is contained in:
parent
b9520a6c3e
commit
29be5e1249
1 changed files with 22 additions and 1 deletions
|
@ -405,8 +405,29 @@ void Sapphire::Zone::updateBNpcs( int64_t tickCount )
|
||||||
removeActor( pBNpc );
|
removeActor( pBNpc );
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
pBNpc->update( tickCount );
|
for( uint32_t x = 0; x < _sizeX; x++ )
|
||||||
|
{
|
||||||
|
for( uint32_t y = 0; y < _sizeY; ++y )
|
||||||
|
{
|
||||||
|
auto cell = getCellPtr( x, y );
|
||||||
|
if( !cell )
|
||||||
|
continue;
|
||||||
|
|
||||||
|
// todo: this is a pretty shit because we will visit the same cells multiple times over
|
||||||
|
// ideally we run a pass every tick and cache active cells during that initial pass over every cell
|
||||||
|
// that way we don't have an expensive lookup for every actor
|
||||||
|
|
||||||
|
if( !isCellActive( x, y ) )
|
||||||
|
continue;
|
||||||
|
|
||||||
|
for( const auto& actor : cell->m_actors )
|
||||||
|
{
|
||||||
|
if( actor->isBattleNpc() )
|
||||||
|
actor->getAsBNpc()->update( tickCount );
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue