aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormegamage <none@none.none>2011-11-10 10:18:32 -0500
committermegamage <none@none.none>2011-11-10 10:18:32 -0500
commit23b3f16f3a4a27b7b24081b725666c5897fdbbee (patch)
tree31ec3e374620a6216df993bd09a580ce1d1c23f1
parent7c1f1b3898320ad7329cf336ecae2abe5ed497fa (diff)
Add some ASSERT in add/remove obj to/from grid.
-rwxr-xr-xsrc/server/game/Grids/Grid.h21
-rwxr-xr-xsrc/server/game/Grids/NGrid.h2
-rwxr-xr-xsrc/server/game/Maps/Map.cpp5
3 files changed, 18 insertions, 10 deletions
diff --git a/src/server/game/Grids/Grid.h b/src/server/game/Grids/Grid.h
index a90915d49f0..cf6eb2471da 100755
--- a/src/server/game/Grids/Grid.h
+++ b/src/server/game/Grids/Grid.h
@@ -58,16 +58,19 @@ class Grid
*/
template<class SPECIFIC_OBJECT> void AddWorldObject(SPECIFIC_OBJECT *obj)
{
- if (!i_objects.template insert<SPECIFIC_OBJECT>(obj))
- ASSERT(false);
+ ASSERT(!obj->GetGridRef().isValid());
+ i_objects.template insert<SPECIFIC_OBJECT>(obj);
+ ASSERT(obj->GetGridRef().isValid());
}
/** an object of interested exits the grid
*/
+ //Actually an unlink is enough, no need to go through the container
template<class SPECIFIC_OBJECT> void RemoveWorldObject(SPECIFIC_OBJECT *obj)
{
- if (!i_objects.template remove<SPECIFIC_OBJECT>(obj))
- ASSERT(false);
+ ASSERT(obj->GetGridRef().isValid());
+ i_objects.template remove<SPECIFIC_OBJECT>(obj);
+ ASSERT(!obj->GetGridRef().isValid());
}
/** Refreshes/update the grid. This required for remote grids.
@@ -104,16 +107,18 @@ class Grid
*/
template<class SPECIFIC_OBJECT> void AddGridObject(SPECIFIC_OBJECT *obj)
{
- if (!i_container.template insert<SPECIFIC_OBJECT>(obj))
- ASSERT(false);
+ ASSERT(!obj->GetGridRef().isValid());
+ i_container.template insert<SPECIFIC_OBJECT>(obj);
+ ASSERT(obj->GetGridRef().isValid());
}
/** Removes a containter type object from the grid
*/
template<class SPECIFIC_OBJECT> void RemoveGridObject(SPECIFIC_OBJECT *obj)
{
- if (!i_container.template remove<SPECIFIC_OBJECT>(obj))
- ASSERT(false);
+ ASSERT(obj->GetGridRef().isValid());
+ i_container.template remove<SPECIFIC_OBJECT>(obj);
+ ASSERT(!obj->GetGridRef().isValid());
}
/*bool NoWorldObjectInGrid() const
diff --git a/src/server/game/Grids/NGrid.h b/src/server/game/Grids/NGrid.h
index b814fd386a5..97a47f7d272 100755
--- a/src/server/game/Grids/NGrid.h
+++ b/src/server/game/Grids/NGrid.h
@@ -120,6 +120,7 @@ class NGrid
void ResetTimeTracker(time_t interval) { i_GridInfo.ResetTimeTracker(interval); }
void UpdateTimeTracker(time_t diff) { i_GridInfo.UpdateTimeTracker(diff); }
+ /*
template<class SPECIFIC_OBJECT> void AddWorldObject(const uint32 x, const uint32 y, SPECIFIC_OBJECT *obj)
{
GetGridType(x, y).AddWorldObject(obj);
@@ -139,6 +140,7 @@ class NGrid
{
GetGridType(x, y).RemoveGridObject(obj);
}
+ */
// Visit all Grids (cells) in NGrid (grid)
template<class T, class TT>
diff --git a/src/server/game/Maps/Map.cpp b/src/server/game/Maps/Map.cpp
index e193325b72e..0c2a808f5c6 100755
--- a/src/server/game/Maps/Map.cpp
+++ b/src/server/game/Maps/Map.cpp
@@ -255,6 +255,7 @@ void Map::AddToGrid(Creature* obj, Cell const& cell)
obj->SetCurrentCell(cell);
}
+//TODO: cell is not needed. Just an unlink is enough.
template<class T>
void Map::RemoveFromGrid(T* obj, Cell const& cell)
{
@@ -287,12 +288,12 @@ void Map::SwitchGridContainers(T* obj, bool on)
if (on)
{
- grid.RemoveGridObject<T>(obj);
+ grid.RemoveGridObject<T>(obj); //not really necessary if there were no ASSERT in remove/add
grid.AddWorldObject<T>(obj);
}
else
{
- grid.RemoveWorldObject<T>(obj);
+ grid.RemoveWorldObject<T>(obj); //not really necessary if there were no ASSERT in remove/add
grid.AddGridObject<T>(obj);
}
obj->m_isWorldObject = on;