mirror of
https://github.com/mangosfour/server.git
synced 2025-12-14 07:37:01 +00:00
Move object update from ObjectAccessor to Map update.
This commit is contained in:
parent
d287a17597
commit
0d1b8038f5
6 changed files with 204 additions and 89 deletions
|
|
@ -562,6 +562,63 @@ bool Map::loaded(const GridPair &p) const
|
|||
|
||||
void Map::Update(const uint32 &t_diff)
|
||||
{
|
||||
resetMarkedCells();
|
||||
|
||||
//TODO: Player guard
|
||||
HashMapHolder<Player>::MapType& playerMap = HashMapHolder<Player>::GetContainer();
|
||||
for(HashMapHolder<Player>::MapType::iterator iter = playerMap.begin(); iter != playerMap.end(); ++iter)
|
||||
{
|
||||
WorldObject* obj = iter->second;
|
||||
|
||||
if(!obj->IsInWorld())
|
||||
continue;
|
||||
|
||||
if(obj->GetMapId() != GetId())
|
||||
continue;
|
||||
|
||||
if(obj->GetInstanceId() != GetInstanceId())
|
||||
continue;
|
||||
|
||||
CellPair standing_cell(MaNGOS::ComputeCellPair(obj->GetPositionX(), obj->GetPositionY()));
|
||||
|
||||
// Check for correctness of standing_cell, it also avoids problems with update_cell
|
||||
if (standing_cell.x_coord >= TOTAL_NUMBER_OF_CELLS_PER_MAP || standing_cell.y_coord >= TOTAL_NUMBER_OF_CELLS_PER_MAP)
|
||||
continue;
|
||||
|
||||
// the overloaded operators handle range checking
|
||||
// so ther's no need for range checking inside the loop
|
||||
CellPair begin_cell(standing_cell), end_cell(standing_cell);
|
||||
begin_cell << 1; begin_cell -= 1; // upper left
|
||||
end_cell >> 1; end_cell += 1; // lower right
|
||||
|
||||
for(uint32 x = begin_cell.x_coord; x <= end_cell.x_coord; ++x)
|
||||
for(uint32 y = begin_cell.y_coord; y <= end_cell.y_coord; ++y)
|
||||
markCell(x,y);
|
||||
}
|
||||
|
||||
MaNGOS::ObjectUpdater updater(t_diff);
|
||||
// for creature
|
||||
TypeContainerVisitor<MaNGOS::ObjectUpdater, GridTypeMapContainer > grid_object_update(updater);
|
||||
// for pets
|
||||
TypeContainerVisitor<MaNGOS::ObjectUpdater, WorldTypeMapContainer > world_object_update(updater);
|
||||
|
||||
for(int x = 0; x < TOTAL_NUMBER_OF_CELLS_PER_MAP; ++x)
|
||||
{
|
||||
for(int y = 0; y < TOTAL_NUMBER_OF_CELLS_PER_MAP; ++y)
|
||||
{
|
||||
if(isCellMarked(x,y))
|
||||
{
|
||||
CellPair pair(x,y);
|
||||
Cell cell(pair);
|
||||
cell.data.Part.reserved = CENTER_DISTRICT;
|
||||
cell.SetNoCreate();
|
||||
CellLock<NullGuard> cell_lock(cell, pair);
|
||||
cell_lock->Visit(cell_lock, grid_object_update, *this);
|
||||
cell_lock->Visit(cell_lock, world_object_update, *this);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Don't unload grids if it's battleground, since we may have manually added GOs,creatures, those doesn't load from DB at grid re-load !
|
||||
// This isn't really bother us, since as soon as we have instanced BG-s, the whole map unloads as the BG gets ended
|
||||
if (IsBattleGroundOrArena())
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue