diff options
author | Gosha <284210+Lordron@users.noreply.github.com> | 2023-04-13 12:52:34 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-04-13 11:52:34 +0200 |
commit | 71b7cc6361d6db9dd445aef617a40b8435393729 (patch) | |
tree | 0d04f46627d1288b9a0e641f0800488f6a3fc919 | |
parent | 9ad420e5318c8cda8b133e65fe7162b1976c0ae8 (diff) |
Change Map::Visit to not call EnsureGridLoaded if cell.NoCreate is true (#28884)
Remove Map::setGridObjectDataLoaded/Map::isGridObjectDataLoaded helpers, we have NGridType object to use methods directly
-rw-r--r-- | src/server/game/Maps/Map.cpp | 7 | ||||
-rw-r--r-- | src/server/game/Maps/Map.h | 12 |
2 files changed, 9 insertions, 10 deletions
diff --git a/src/server/game/Maps/Map.cpp b/src/server/game/Maps/Map.cpp index 1fc947a43c2..a206b6529d0 100644 --- a/src/server/game/Maps/Map.cpp +++ b/src/server/game/Maps/Map.cpp @@ -534,11 +534,11 @@ bool Map::EnsureGridLoaded(Cell const& cell) NGridType *grid = getNGrid(cell.GridX(), cell.GridY()); ASSERT(grid != nullptr); - if (!isGridObjectDataLoaded(cell.GridX(), cell.GridY())) + if (!grid->isGridObjectDataLoaded()) { TC_LOG_DEBUG("maps", "Loading grid[%u, %u] for map %u instance %u", cell.GridX(), cell.GridY(), GetId(), i_InstanceId); - setGridObjectDataLoaded(true, cell.GridX(), cell.GridY()); + grid->setGridObjectDataLoaded(true); ObjectGridLoader loader(*grid, this, cell); loader.LoadN(); @@ -709,7 +709,8 @@ bool Map::AddToMap(Transport* obj) bool Map::IsGridLoaded(GridCoord const& p) const { - return (getNGrid(p.x_coord, p.y_coord) && isGridObjectDataLoaded(p.x_coord, p.y_coord)); + NGridType* grid = getNGrid(p.x_coord, p.y_coord); + return grid && grid->isGridObjectDataLoaded(); } void Map::VisitNearbyCellsOf(WorldObject* obj, TypeContainerVisitor<Trinity::ObjectUpdater, GridTypeMapContainer> &gridVisitor, TypeContainerVisitor<Trinity::ObjectUpdater, WorldTypeMapContainer> &worldVisitor) diff --git a/src/server/game/Maps/Map.h b/src/server/game/Maps/Map.h index c926a00f27f..66c8e0c9059 100644 --- a/src/server/game/Maps/Map.h +++ b/src/server/game/Maps/Map.h @@ -696,9 +696,6 @@ class TC_GAME_API Map : public GridRefManager<NGridType> return i_grids[x][y]; } - bool isGridObjectDataLoaded(uint32 x, uint32 y) const { return getNGrid(x, y)->isGridObjectDataLoaded(); } - void setGridObjectDataLoaded(bool pLoaded, uint32 x, uint32 y) { getNGrid(x, y)->setGridObjectDataLoaded(pLoaded); } - void setNGrid(NGridType* grid, uint32 x, uint32 y); void ScriptsProcess(); @@ -985,10 +982,11 @@ inline void Map::Visit(Cell const& cell, TypeContainerVisitor<T, CONTAINER>& vis const uint32 cell_x = cell.CellX(); const uint32 cell_y = cell.CellY(); - if (!cell.NoCreate() || IsGridLoaded(GridCoord(x, y))) - { + if (!cell.NoCreate()) EnsureGridLoaded(cell); - getNGrid(x, y)->VisitGrid(cell_x, cell_y, visitor); - } + + NGridType* grid = getNGrid(x, y); + if (grid && grid->isGridObjectDataLoaded()) + grid->VisitGrid(cell_x, cell_y, visitor); } #endif |