aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMatan Shukry <matanshukry@gmail.com>2021-03-28 16:26:28 +0300
committerGitHub <noreply@github.com>2021-03-28 15:26:28 +0200
commita8fb7109b78bdc951292c9de7eddcce59393afe9 (patch)
tree9beb2e176f389d57dc2aaa19d01946c0bd7163c5 /src
parent0461826689dad8f318e86395ce1060c8f29f7920 (diff)
Core/Maps: Refactor duplicated code from all ***CellRelocation and CheckGridIntegrity into single templated function (#26231)
Diffstat (limited to 'src')
-rw-r--r--src/server/game/Maps/Map.cpp313
-rw-r--r--src/server/game/Maps/Map.h6
2 files changed, 77 insertions, 242 deletions
diff --git a/src/server/game/Maps/Map.cpp b/src/server/game/Maps/Map.cpp
index b92b1b71c68..25c57136eef 100644
--- a/src/server/game/Maps/Map.cpp
+++ b/src/server/game/Maps/Map.cpp
@@ -1127,6 +1127,24 @@ void Map::RemoveFromMap(Transport* obj, bool remove)
}
}
+template <typename T>
+/*static*/ bool Map::CheckGridIntegrity(T* object, bool moved, char const* objType)
+{
+ Cell const& cur_cell = object->GetCurrentCell();
+ Cell xy_cell(object->GetPositionX(), object->GetPositionY());
+ if (xy_cell != cur_cell)
+ {
+ TC_LOG_DEBUG("maps", "%s (%s) X: %f Y: %f (%s) is in grid[%u, %u]cell[%u, %u] instead of grid[%u, %u]cell[%u, %u]",
+ objType, object->GetGUID().ToString().c_str(),
+ object->GetPositionX(), object->GetPositionY(), (moved ? "final" : "original"),
+ cur_cell.GridX(), cur_cell.GridY(), cur_cell.CellX(), cur_cell.CellY(),
+ xy_cell.GridX(), xy_cell.GridY(), xy_cell.CellX(), xy_cell.CellY());
+ return true; // not crash at error, just output error in debug mode
+ }
+
+ return true;
+}
+
void Map::PlayerRelocation(Player* player, float x, float y, float z, float orientation)
{
ASSERT(player);
@@ -1162,9 +1180,8 @@ void Map::PlayerRelocation(Player* player, float x, float y, float z, float orie
void Map::CreatureRelocation(Creature* creature, float x, float y, float z, float ang, bool respawnRelocationOnFail)
{
- ASSERT(CheckGridIntegrity(creature, false));
+ ASSERT(CheckGridIntegrity(creature, false, "Creature"));
- Cell old_cell = creature->GetCurrentCell();
Cell new_cell(x, y);
if (!respawnRelocationOnFail && !getNGrid(new_cell.GridX(), new_cell.GridY()))
@@ -1176,12 +1193,13 @@ void Map::CreatureRelocation(Creature* creature, float x, float y, float z, floa
if (creature->HasUnitMovementFlag(MOVEMENTFLAG_HOVER))
z += creature->m_unitData->HoverHeight;
+ Cell old_cell = creature->GetCurrentCell();
// delay creature move for grid/cell to grid/cell moves
if (old_cell.DiffCell(new_cell) || old_cell.DiffGrid(new_cell))
{
- #ifdef TRINITY_DEBUG
+#ifdef TRINITY_DEBUG
TC_LOG_DEBUG("maps", "Creature (%s Entry: %u) added to moving list from grid[%u, %u]cell[%u, %u] to grid[%u, %u]cell[%u, %u].", creature->GetGUID().ToString().c_str(), creature->GetEntry(), old_cell.GridX(), old_cell.GridY(), old_cell.CellX(), old_cell.CellY(), new_cell.GridX(), new_cell.GridY(), new_cell.CellX(), new_cell.CellY());
- #endif
+#endif
AddCreatureToMoveList(creature, x, y, z, ang);
// in diffcell/diffgrid case notifiers called at finishing move creature in Map::MoveAllCreaturesInMoveList
}
@@ -1195,20 +1213,19 @@ void Map::CreatureRelocation(Creature* creature, float x, float y, float z, floa
RemoveCreatureFromMoveList(creature);
}
- ASSERT(CheckGridIntegrity(creature, true));
+ ASSERT(CheckGridIntegrity(creature, true, "Creature"));
}
void Map::GameObjectRelocation(GameObject* go, float x, float y, float z, float orientation, bool respawnRelocationOnFail)
{
- Cell integrity_check(go->GetPositionX(), go->GetPositionY());
- Cell old_cell = go->GetCurrentCell();
-
- ASSERT(integrity_check == old_cell);
+ ASSERT(CheckGridIntegrity(go, false, "GameObject"));
Cell new_cell(x, y);
if (!respawnRelocationOnFail && !getNGrid(new_cell.GridX(), new_cell.GridY()))
return;
+ Cell old_cell = go->GetCurrentCell();
+
// delay creature move for grid/cell to grid/cell moves
if (old_cell.DiffCell(new_cell) || old_cell.DiffGrid(new_cell))
{
@@ -1227,22 +1244,19 @@ void Map::GameObjectRelocation(GameObject* go, float x, float y, float z, float
RemoveGameObjectFromMoveList(go);
}
- old_cell = go->GetCurrentCell();
- integrity_check = Cell(go->GetPositionX(), go->GetPositionY());
- ASSERT(integrity_check == old_cell);
+ ASSERT(CheckGridIntegrity(go, true, "GameObject"));
}
void Map::DynamicObjectRelocation(DynamicObject* dynObj, float x, float y, float z, float orientation)
{
- Cell integrity_check(dynObj->GetPositionX(), dynObj->GetPositionY());
- Cell old_cell = dynObj->GetCurrentCell();
-
- ASSERT(integrity_check == old_cell);
+ ASSERT(CheckGridIntegrity(dynObj, false, "DynamicObject"));
Cell new_cell(x, y);
if (!getNGrid(new_cell.GridX(), new_cell.GridY()))
return;
+ Cell old_cell = dynObj->GetCurrentCell();
+
// delay creature move for grid/cell to grid/cell moves
if (old_cell.DiffCell(new_cell) || old_cell.DiffGrid(new_cell))
{
@@ -1260,22 +1274,19 @@ void Map::DynamicObjectRelocation(DynamicObject* dynObj, float x, float y, float
RemoveDynamicObjectFromMoveList(dynObj);
}
- old_cell = dynObj->GetCurrentCell();
- integrity_check = Cell(dynObj->GetPositionX(), dynObj->GetPositionY());
- ASSERT(integrity_check == old_cell);
+ ASSERT(CheckGridIntegrity(dynObj, true, "DynamicObject"));
}
void Map::AreaTriggerRelocation(AreaTrigger* at, float x, float y, float z, float orientation)
{
- Cell integrity_check(at->GetPositionX(), at->GetPositionY());
- Cell old_cell = at->GetCurrentCell();
-
- ASSERT(integrity_check == old_cell);
+ ASSERT(CheckGridIntegrity(at, false, "AreaTrigger"));
Cell new_cell(x, y);
if (!getNGrid(new_cell.GridX(), new_cell.GridY()))
return;
+ Cell old_cell = at->GetCurrentCell();
+
// delay areatrigger move for grid/cell to grid/cell moves
if (old_cell.DiffCell(new_cell) || old_cell.DiffGrid(new_cell))
{
@@ -1293,9 +1304,7 @@ void Map::AreaTriggerRelocation(AreaTrigger* at, float x, float y, float z, floa
RemoveAreaTriggerFromMoveList(at);
}
- old_cell = at->GetCurrentCell();
- integrity_check = Cell(at->GetPositionX(), at->GetPositionY());
- ASSERT(integrity_check == old_cell);
+ ASSERT(CheckGridIntegrity(at, true, "AreaTrigger"));
}
void Map::AddCreatureToMoveList(Creature* c, float x, float y, float z, float ang)
@@ -1555,248 +1564,87 @@ void Map::MoveAllAreaTriggersInMoveList()
_areaTriggersToMoveLock = false;
}
-bool Map::CreatureCellRelocation(Creature* c, Cell new_cell)
+template <typename T>
+bool Map::MapObjectCellRelocation(T* object, Cell new_cell, char const* objType)
{
- Cell const& old_cell = c->GetCurrentCell();
+ Cell const& old_cell = object->GetCurrentCell();
if (!old_cell.DiffGrid(new_cell)) // in same grid
{
// if in same cell then none do
if (old_cell.DiffCell(new_cell))
{
- #ifdef TRINITY_DEBUG
- TC_LOG_DEBUG("maps", "Creature (%s Entry: %u) moved in grid[%u, %u] from cell[%u, %u] to cell[%u, %u].", c->GetGUID().ToString().c_str(), c->GetEntry(), old_cell.GridX(), old_cell.GridY(), old_cell.CellX(), old_cell.CellY(), new_cell.CellX(), new_cell.CellY());
- #endif
+#ifdef TRINITY_DEBUG
+ TC_LOG_DEBUG("maps", "%s (%s Entry: %u) moved in grid[%u, %u] from cell[%u, %u] to cell[%u, %u].", objType, object->GetGUID().ToString().c_str(), object->GetEntry(), old_cell.GridX(), old_cell.GridY(), old_cell.CellX(), old_cell.CellY(), new_cell.CellX(), new_cell.CellY());
+#endif
- c->RemoveFromGrid();
- AddToGrid(c, new_cell);
+ object->RemoveFromGrid();
+ AddToGrid(object, new_cell);
}
else
{
- #ifdef TRINITY_DEBUG
- TC_LOG_DEBUG("maps", "Creature (%s Entry: %u) moved in same grid[%u, %u]cell[%u, %u].", c->GetGUID().ToString().c_str(), c->GetEntry(), old_cell.GridX(), old_cell.GridY(), old_cell.CellX(), old_cell.CellY());
- #endif
+#ifdef TRINITY_DEBUG
+ TC_LOG_DEBUG("maps", "%s (%s Entry: %u) moved in same grid[%u, %u]cell[%u, %u].", objType, object->GetGUID().ToString().c_str(), object->GetEntry(), old_cell.GridX(), old_cell.GridY(), old_cell.CellX(), old_cell.CellY());
+#endif
}
return true;
}
// in diff. grids but active creature
- if (c->isActiveObject())
+ if (object->isActiveObject())
{
- EnsureGridLoadedForActiveObject(new_cell, c);
+ EnsureGridLoadedForActiveObject(new_cell, object);
- #ifdef TRINITY_DEBUG
- TC_LOG_DEBUG("maps", "Active creature (%s Entry: %u) moved from grid[%u, %u]cell[%u, %u] to grid[%u, %u]cell[%u, %u].", c->GetGUID().ToString().c_str(), c->GetEntry(), old_cell.GridX(), old_cell.GridY(), old_cell.CellX(), old_cell.CellY(), new_cell.GridX(), new_cell.GridY(), new_cell.CellX(), new_cell.CellY());
- #endif
+#ifdef TRINITY_DEBUG
+ TC_LOG_DEBUG("maps", "Active %s (%s Entry: %u) moved from grid[%u, %u]cell[%u, %u] to grid[%u, %u]cell[%u, %u].", objType, object->GetGUID().ToString().c_str(), object->GetEntry(), old_cell.GridX(), old_cell.GridY(), old_cell.CellX(), old_cell.CellY(), new_cell.GridX(), new_cell.GridY(), new_cell.CellX(), new_cell.CellY());
+#endif
- c->RemoveFromGrid();
- AddToGrid(c, new_cell);
+ object->RemoveFromGrid();
+ AddToGrid(object, new_cell);
return true;
}
- // in diff. loaded grid normal creature
+ // in diff. loaded grid normal object
if (IsGridLoaded(GridCoord(new_cell.GridX(), new_cell.GridY())))
{
- #ifdef TRINITY_DEBUG
- TC_LOG_DEBUG("maps", "Creature (%s Entry: %u) moved from grid[%u, %u]cell[%u, %u] to grid[%u, %u]cell[%u, %u].", c->GetGUID().ToString().c_str(), c->GetEntry(), old_cell.GridX(), old_cell.GridY(), old_cell.CellX(), old_cell.CellY(), new_cell.GridX(), new_cell.GridY(), new_cell.CellX(), new_cell.CellY());
- #endif
+#ifdef TRINITY_DEBUG
+ TC_LOG_DEBUG("maps", "%s (%s Entry: %u) moved from grid[%u, %u]cell[%u, %u] to grid[%u, %u]cell[%u, %u].", objType, object->GetGUID().ToString().c_str(), object->GetEntry(), old_cell.GridX(), old_cell.GridY(), old_cell.CellX(), old_cell.CellY(), new_cell.GridX(), new_cell.GridY(), new_cell.CellX(), new_cell.CellY());
+#endif
- c->RemoveFromGrid();
+ object->RemoveFromGrid();
EnsureGridCreated(GridCoord(new_cell.GridX(), new_cell.GridY()));
- AddToGrid(c, new_cell);
+ AddToGrid(object, new_cell);
return true;
}
- // fail to move: normal creature attempt move to unloaded grid
- #ifdef TRINITY_DEBUG
- TC_LOG_DEBUG("maps", "Creature (%s Entry: %u) attempted to move from grid[%u, %u]cell[%u, %u] to unloaded grid[%u, %u]cell[%u, %u].", c->GetGUID().ToString().c_str(), c->GetEntry(), old_cell.GridX(), old_cell.GridY(), old_cell.CellX(), old_cell.CellY(), new_cell.GridX(), new_cell.GridY(), new_cell.CellX(), new_cell.CellY());
- #endif
+ // fail to move: normal object attempt move to unloaded grid
+#ifdef TRINITY_DEBUG
+ TC_LOG_DEBUG("maps", "%s (%s Entry: %u) attempted to move from grid[%u, %u]cell[%u, %u] to unloaded grid[%u, %u]cell[%u, %u].", objType, object->GetGUID().ToString().c_str(), object->GetEntry(), old_cell.GridX(), old_cell.GridY(), old_cell.CellX(), old_cell.CellY(), new_cell.GridX(), new_cell.GridY(), new_cell.CellX(), new_cell.CellY());
+#endif
+ (void)objType;
return false;
}
-bool Map::GameObjectCellRelocation(GameObject* go, Cell new_cell)
+bool Map::CreatureCellRelocation(Creature* c, Cell new_cell)
{
- Cell const& old_cell = go->GetCurrentCell();
- if (!old_cell.DiffGrid(new_cell)) // in same grid
- {
- // if in same cell then none do
- if (old_cell.DiffCell(new_cell))
- {
- #ifdef TRINITY_DEBUG
- TC_LOG_DEBUG("maps", "GameObject (%s Entry: %u) moved in grid[%u, %u] from cell[%u, %u] to cell[%u, %u].", go->GetGUID().ToString().c_str(), go->GetEntry(), old_cell.GridX(), old_cell.GridY(), old_cell.CellX(), old_cell.CellY(), new_cell.CellX(), new_cell.CellY());
- #endif
-
- go->RemoveFromGrid();
- AddToGrid(go, new_cell);
- }
- else
- {
- #ifdef TRINITY_DEBUG
- TC_LOG_DEBUG("maps", "GameObject (%s Entry: %u) moved in same grid[%u, %u]cell[%u, %u].", go->GetGUID().ToString().c_str(), go->GetEntry(), old_cell.GridX(), old_cell.GridY(), old_cell.CellX(), old_cell.CellY());
- #endif
- }
-
- return true;
- }
-
- // in diff. grids but active GameObject
- if (go->isActiveObject())
- {
- EnsureGridLoadedForActiveObject(new_cell, go);
-
- #ifdef TRINITY_DEBUG
- TC_LOG_DEBUG("maps", "Active GameObject (%s Entry: %u) moved from grid[%u, %u]cell[%u, %u] to grid[%u, %u]cell[%u, %u].", go->GetGUID().ToString().c_str(), go->GetEntry(), old_cell.GridX(), old_cell.GridY(), old_cell.CellX(), old_cell.CellY(), new_cell.GridX(), new_cell.GridY(), new_cell.CellX(), new_cell.CellY());
- #endif
-
- go->RemoveFromGrid();
- AddToGrid(go, new_cell);
-
- return true;
- }
-
- // in diff. loaded grid normal GameObject
- if (IsGridLoaded(GridCoord(new_cell.GridX(), new_cell.GridY())))
- {
- #ifdef TRINITY_DEBUG
- TC_LOG_DEBUG("maps", "GameObject (%s Entry: %u) moved from grid[%u, %u]cell[%u, %u] to grid[%u, %u]cell[%u, %u].", go->GetGUID().ToString().c_str(), go->GetEntry(), old_cell.GridX(), old_cell.GridY(), old_cell.CellX(), old_cell.CellY(), new_cell.GridX(), new_cell.GridY(), new_cell.CellX(), new_cell.CellY());
- #endif
-
- go->RemoveFromGrid();
- EnsureGridCreated(GridCoord(new_cell.GridX(), new_cell.GridY()));
- AddToGrid(go, new_cell);
-
- return true;
- }
+ return MapObjectCellRelocation(c, new_cell, "Creature");
+}
- // fail to move: normal GameObject attempt move to unloaded grid
- #ifdef TRINITY_DEBUG
- TC_LOG_DEBUG("maps", "GameObject (%s Entry: %u) attempted to move from grid[%u, %u]cell[%u, %u] to unloaded grid[%u, %u]cell[%u, %u].", go->GetGUID().ToString().c_str(), go->GetEntry(), old_cell.GridX(), old_cell.GridY(), old_cell.CellX(), old_cell.CellY(), new_cell.GridX(), new_cell.GridY(), new_cell.CellX(), new_cell.CellY());
- #endif
- return false;
+bool Map::GameObjectCellRelocation(GameObject* go, Cell new_cell)
+{
+ return MapObjectCellRelocation(go, new_cell, "GameObject");
}
bool Map::DynamicObjectCellRelocation(DynamicObject* go, Cell new_cell)
{
- Cell const& old_cell = go->GetCurrentCell();
- if (!old_cell.DiffGrid(new_cell)) // in same grid
- {
- // if in same cell then none do
- if (old_cell.DiffCell(new_cell))
- {
- #ifdef TRINITY_DEBUG
- TC_LOG_DEBUG("maps", "DynamicObject (%s) moved in grid[%u, %u] from cell[%u, %u] to cell[%u, %u].", go->GetGUID().ToString().c_str(), old_cell.GridX(), old_cell.GridY(), old_cell.CellX(), old_cell.CellY(), new_cell.CellX(), new_cell.CellY());
- #endif
-
- go->RemoveFromGrid();
- AddToGrid(go, new_cell);
- }
- else
- {
- #ifdef TRINITY_DEBUG
- TC_LOG_DEBUG("maps", "DynamicObject (%s) moved in same grid[%u, %u]cell[%u, %u].", go->GetGUID().ToString().c_str(), old_cell.GridX(), old_cell.GridY(), old_cell.CellX(), old_cell.CellY());
- #endif
- }
-
- return true;
- }
-
- // in diff. grids but active GameObject
- if (go->isActiveObject())
- {
- EnsureGridLoadedForActiveObject(new_cell, go);
-
- #ifdef TRINITY_DEBUG
- TC_LOG_DEBUG("maps", "Active DynamicObject (%s) moved from grid[%u, %u]cell[%u, %u] to grid[%u, %u]cell[%u, %u].", go->GetGUID().ToString().c_str(), old_cell.GridX(), old_cell.GridY(), old_cell.CellX(), old_cell.CellY(), new_cell.GridX(), new_cell.GridY(), new_cell.CellX(), new_cell.CellY());
- #endif
-
- go->RemoveFromGrid();
- AddToGrid(go, new_cell);
-
- return true;
- }
-
- // in diff. loaded grid normal GameObject
- if (IsGridLoaded(GridCoord(new_cell.GridX(), new_cell.GridY())))
- {
- #ifdef TRINITY_DEBUG
- TC_LOG_DEBUG("maps", "DynamicObject (%s) moved from grid[%u, %u]cell[%u, %u] to grid[%u, %u]cell[%u, %u].", go->GetGUID().ToString().c_str(), old_cell.GridX(), old_cell.GridY(), old_cell.CellX(), old_cell.CellY(), new_cell.GridX(), new_cell.GridY(), new_cell.CellX(), new_cell.CellY());
- #endif
-
- go->RemoveFromGrid();
- EnsureGridCreated(GridCoord(new_cell.GridX(), new_cell.GridY()));
- AddToGrid(go, new_cell);
-
- return true;
- }
-
- // fail to move: normal GameObject attempt move to unloaded grid
- #ifdef TRINITY_DEBUG
- TC_LOG_DEBUG("maps", "DynamicObject (%s) attempted to move from grid[%u, %u]cell[%u, %u] to unloaded grid[%u, %u]cell[%u, %u].", go->GetGUID().ToString().c_str(), old_cell.GridX(), old_cell.GridY(), old_cell.CellX(), old_cell.CellY(), new_cell.GridX(), new_cell.GridY(), new_cell.CellX(), new_cell.CellY());
- #endif
- return false;
+ return MapObjectCellRelocation(go, new_cell, "DynamicObject");
}
bool Map::AreaTriggerCellRelocation(AreaTrigger* at, Cell new_cell)
{
- Cell const& old_cell = at->GetCurrentCell();
- if (!old_cell.DiffGrid(new_cell)) // in same grid
- {
- // if in same cell then none do
- if (old_cell.DiffCell(new_cell))
- {
-#ifdef TRINITY_DEBUG
- TC_LOG_DEBUG("maps", "AreaTrigger (%s) moved in grid[%u, %u] from cell[%u, %u] to cell[%u, %u].", at->GetGUID().ToString().c_str(), old_cell.GridX(), old_cell.GridY(), old_cell.CellX(), old_cell.CellY(), new_cell.CellX(), new_cell.CellY());
-#endif
-
- at->RemoveFromGrid();
- AddToGrid(at, new_cell);
- }
- else
- {
-#ifdef TRINITY_DEBUG
- TC_LOG_DEBUG("maps", "AreaTrigger (%s) moved in same grid[%u, %u]cell[%u, %u].", at->GetGUID().ToString().c_str(), old_cell.GridX(), old_cell.GridY(), old_cell.CellX(), old_cell.CellY());
-#endif
- }
-
- return true;
- }
-
- // in diff. grids but active AreaTrigger
- if (at->isActiveObject())
- {
- EnsureGridLoadedForActiveObject(new_cell, at);
-
-#ifdef TRINITY_DEBUG
- TC_LOG_DEBUG("maps", "Active AreaTrigger (%s) moved from grid[%u, %u]cell[%u, %u] to grid[%u, %u]cell[%u, %u].", at->GetGUID().ToString().c_str(), old_cell.GridX(), old_cell.GridY(), old_cell.CellX(), old_cell.CellY(), new_cell.GridX(), new_cell.GridY(), new_cell.CellX(), new_cell.CellY());
-#endif
-
- at->RemoveFromGrid();
- AddToGrid(at, new_cell);
-
- return true;
- }
-
- // in diff. loaded grid normal AreaTrigger
- if (IsGridLoaded(GridCoord(new_cell.GridX(), new_cell.GridY())))
- {
-#ifdef TRINITY_DEBUG
- TC_LOG_DEBUG("maps", "AreaTrigger (%s) moved from grid[%u, %u]cell[%u, %u] to grid[%u, %u]cell[%u, %u].", at->GetGUID().ToString().c_str(), old_cell.GridX(), old_cell.GridY(), old_cell.CellX(), old_cell.CellY(), new_cell.GridX(), new_cell.GridY(), new_cell.CellX(), new_cell.CellY());
-#endif
-
- at->RemoveFromGrid();
- EnsureGridCreated(GridCoord(new_cell.GridX(), new_cell.GridY()));
- AddToGrid(at, new_cell);
-
- return true;
- }
-
- // fail to move: normal AreaTrigger attempt move to unloaded grid
-#ifdef TRINITY_DEBUG
- TC_LOG_DEBUG("maps", "AreaTrigger (%s) attempted to move from grid[%u, %u]cell[%u, %u] to unloaded grid[%u, %u]cell[%u, %u].", at->GetGUID().ToString().c_str(), old_cell.GridX(), old_cell.GridY(), old_cell.CellX(), old_cell.CellY(), new_cell.GridX(), new_cell.GridY(), new_cell.CellX(), new_cell.CellY());
-#endif
- return false;
+ return MapObjectCellRelocation(at, new_cell, "AreaTrigger");
}
bool Map::CreatureRespawnRelocation(Creature* c, bool diffGridOnly)
@@ -3104,23 +2952,6 @@ bool Map::IsUnderWater(PhaseShift const& phaseShift, float x, float y, float z)
return (GetLiquidStatus(phaseShift, x, y, z, MAP_LIQUID_TYPE_WATER | MAP_LIQUID_TYPE_OCEAN) & LIQUID_MAP_UNDER_WATER) != 0;
}
-bool Map::CheckGridIntegrity(Creature* c, bool moved) const
-{
- Cell const& cur_cell = c->GetCurrentCell();
- Cell xy_cell(c->GetPositionX(), c->GetPositionY());
- if (xy_cell != cur_cell)
- {
- TC_LOG_DEBUG("maps", "Creature (%s) X: %f Y: %f (%s) is in grid[%u, %u]cell[%u, %u] instead of grid[%u, %u]cell[%u, %u]",
- c->GetGUID().ToString().c_str(),
- c->GetPositionX(), c->GetPositionY(), (moved ? "final" : "original"),
- cur_cell.GridX(), cur_cell.GridY(), cur_cell.CellX(), cur_cell.CellY(),
- xy_cell.GridX(), xy_cell.GridY(), xy_cell.CellX(), xy_cell.CellY());
- return true; // not crash at error, just output error in debug mode
- }
-
- return true;
-}
-
char const* Map::GetMapName() const
{
return i_mapEntry ? i_mapEntry->MapName[sWorld->GetDefaultDbcLocale()] : "UNNAMEDMAP\x0";
diff --git a/src/server/game/Maps/Map.h b/src/server/game/Maps/Map.h
index 4288037297e..a58dc644d79 100644
--- a/src/server/game/Maps/Map.h
+++ b/src/server/game/Maps/Map.h
@@ -433,7 +433,8 @@ class TC_GAME_API Map : public GridRefManager<NGridType>
bool GameObjectRespawnRelocation(GameObject* go, bool diffGridOnly);
// assert print helper
- bool CheckGridIntegrity(Creature* c, bool moved) const;
+ template <typename T>
+ static bool CheckGridIntegrity(T* object, bool moved, char const* objType);
uint32 GetInstanceId() const { return i_InstanceId; }
@@ -660,6 +661,9 @@ class TC_GAME_API Map : public GridRefManager<NGridType>
void SendInitSelf(Player* player);
+ template <typename T>
+ bool MapObjectCellRelocation(T* object, Cell new_cell, char const* objType);
+
bool CreatureCellRelocation(Creature* creature, Cell new_cell);
bool GameObjectCellRelocation(GameObject* go, Cell new_cell);
bool DynamicObjectCellRelocation(DynamicObject* go, Cell new_cell);