From 9403ff03e792154b5709a05d8dfdd7da123ce9b5 Mon Sep 17 00:00:00 2001 From: megamage Date: Tue, 11 Aug 2009 16:14:45 -0500 Subject: *Only use m_isWorldObject to check if an object is in grid or world. --HG-- branch : trunk --- src/game/Map.cpp | 98 +++++++------------------------------------------------- 1 file changed, 12 insertions(+), 86 deletions(-) (limited to 'src/game/Map.cpp') diff --git a/src/game/Map.cpp b/src/game/Map.cpp index 5aeb043a92f..e10ee1a2b94 100644 --- a/src/game/Map.cpp +++ b/src/game/Map.cpp @@ -221,104 +221,30 @@ Map::Map(uint32 id, time_t expiry, uint32 InstanceId, uint8 SpawnMode, Map* _par template void Map::AddToGrid(T* obj, NGridType *grid, Cell const& cell) { - (*grid)(cell.CellX(), cell.CellY()).template AddGridObject(obj, obj->GetGUID()); -} - -template<> -void Map::AddToGrid(Player* obj, NGridType *grid, Cell const& cell) -{ - (*grid)(cell.CellX(), cell.CellY()).AddWorldObject(obj, obj->GetGUID()); + if(obj->m_isWorldObject) + (*grid)(cell.CellX(), cell.CellY()).template AddWorldObject(obj, obj->GetGUID()); + else + (*grid)(cell.CellX(), cell.CellY()).template AddGridObject(obj, obj->GetGUID()); } template<> -void Map::AddToGrid(Corpse *obj, NGridType *grid, Cell const& cell) +void Map::AddToGrid(Creature* obj, NGridType *grid, Cell const& cell) { - // add to world object registry in grid - if(obj->GetType()!=CORPSE_BONES) - { + if(obj->m_isWorldObject) (*grid)(cell.CellX(), cell.CellY()).AddWorldObject(obj, obj->GetGUID()); - } - // add to grid object store else - { (*grid)(cell.CellX(), cell.CellY()).AddGridObject(obj, obj->GetGUID()); - } -} -template<> -void Map::AddToGrid(Creature* obj, NGridType *grid, Cell const& cell) -{ - // add to world object registry in grid - if(obj->isWorldCreature() || obj->IsTempWorldObject) - { - (*grid)(cell.CellX(), cell.CellY()).AddWorldObject(obj, obj->GetGUID()); - } - // add to grid object store - else - { - (*grid)(cell.CellX(), cell.CellY()).AddGridObject(obj, obj->GetGUID()); - } obj->SetCurrentCell(cell); } -template<> -void Map::AddToGrid(DynamicObject* obj, NGridType *grid, Cell const& cell) -{ - if(obj->isActiveObject()) // only farsight - (*grid)(cell.CellX(), cell.CellY()).AddWorldObject(obj, obj->GetGUID()); - else - (*grid)(cell.CellX(), cell.CellY()).AddGridObject(obj, obj->GetGUID()); -} - template void Map::RemoveFromGrid(T* obj, NGridType *grid, Cell const& cell) { - (*grid)(cell.CellX(), cell.CellY()).template RemoveGridObject(obj, obj->GetGUID()); -} - -template<> -void Map::RemoveFromGrid(Player* obj, NGridType *grid, Cell const& cell) -{ - (*grid)(cell.CellX(), cell.CellY()).RemoveWorldObject(obj, obj->GetGUID()); -} - -template<> -void Map::RemoveFromGrid(Corpse *obj, NGridType *grid, Cell const& cell) -{ - // remove from world object registry in grid - if(obj->GetType()!=CORPSE_BONES) - { - (*grid)(cell.CellX(), cell.CellY()).RemoveWorldObject(obj, obj->GetGUID()); - } - // remove from grid object store - else - { - (*grid)(cell.CellX(), cell.CellY()).RemoveGridObject(obj, obj->GetGUID()); - } -} - -template<> -void Map::RemoveFromGrid(Creature* obj, NGridType *grid, Cell const& cell) -{ - // remove from world object registry in grid - if(obj->isWorldCreature() || obj->IsTempWorldObject) - { - (*grid)(cell.CellX(), cell.CellY()).RemoveWorldObject(obj, obj->GetGUID()); - } - // remove from grid object store - else - { - (*grid)(cell.CellX(), cell.CellY()).RemoveGridObject(obj, obj->GetGUID()); - } -} - -template<> -void Map::RemoveFromGrid(DynamicObject* obj, NGridType *grid, Cell const& cell) -{ - if(obj->isActiveObject()) // only farsight - (*grid)(cell.CellX(), cell.CellY()).RemoveWorldObject(obj, obj->GetGUID()); + if(obj->m_isWorldObject) + (*grid)(cell.CellX(), cell.CellY()).template RemoveWorldObject(obj, obj->GetGUID()); else - (*grid)(cell.CellX(), cell.CellY()).RemoveGridObject(obj, obj->GetGUID()); + (*grid)(cell.CellX(), cell.CellY()).template RemoveGridObject(obj, obj->GetGUID()); } template @@ -361,11 +287,11 @@ void Map::SwitchGridContainers(T* obj, bool on) assert(false); }*/ } - obj->IsTempWorldObject = on; + obj->m_isWorldObject = on; } template void Map::SwitchGridContainers(Creature *, bool); -template void Map::SwitchGridContainers(DynamicObject *, bool); +//template void Map::SwitchGridContainers(DynamicObject *, bool); template void Map::DeleteFromWorld(T* obj) @@ -2223,7 +2149,7 @@ void Map::RemoveAllObjectsInRemoveList() switch(obj->GetTypeId()) { case TYPEID_UNIT: - if(!((Creature*)obj)->isWorldCreature()) + if(!((Creature*)obj)->isPet()) SwitchGridContainers((Creature*)obj, on); break; } -- cgit v1.2.3