Add some ASSERT in add/remove obj to/from grid.
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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>
|
||||
|
||||
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user