diff options
author | megamage <none@none> | 2009-08-25 15:12:22 -0500 |
---|---|---|
committer | megamage <none@none> | 2009-08-25 15:12:22 -0500 |
commit | 1f88411cccdba1e2b8ad00b23dea37332c481a5c (patch) | |
tree | fb8873ba3437f2abb63539a4643d56add9fe89d6 | |
parent | df4fe8c4dc65c43635ae12ba1b6f7f196ea566dd (diff) |
*Delete object after map update. This will make mtmap safer.
--HG--
branch : trunk
-rw-r--r-- | src/game/Map.cpp | 56 | ||||
-rw-r--r-- | src/game/Map.h | 8 | ||||
-rw-r--r-- | src/game/MapInstanced.cpp | 20 | ||||
-rw-r--r-- | src/game/MapInstanced.h | 5 | ||||
-rw-r--r-- | src/game/MapManager.cpp | 3 |
5 files changed, 41 insertions, 51 deletions
diff --git a/src/game/Map.cpp b/src/game/Map.cpp index c8c7140b0e5..40bdf02671e 100644 --- a/src/game/Map.cpp +++ b/src/game/Map.cpp @@ -597,6 +597,13 @@ void Map::Update(const uint32 &t_diff) plr->Update(t_diff); } + m_notifyTimer.Update(t_diff); + if(m_notifyTimer.Passed()) + { + m_notifyTimer.Reset(); + RelocationNotify(); + } + /// update active cells around players and active objects resetMarkedCells(); @@ -702,30 +709,6 @@ void Map::Update(const uint32 &t_diff) } } - MoveAllCreaturesInMoveList(); - RemoveAllObjectsInRemoveList(); - - m_notifyTimer.Update(t_diff); - if(m_notifyTimer.Passed()) - { - m_notifyTimer.Reset(); - RelocationNotify(); - } - - // Don't unload grids if it's battleground, since we may have manually added GOs,creatures, those doesn't load from DB at grid re-load ! - // This isn't really bother us, since as soon as we have instanced BG-s, the whole map unloads as the BG gets ended - if (!IsBattleGroundOrArena()) - { - for (GridRefManager<NGridType>::iterator i = GridRefManager<NGridType>::begin(); i != GridRefManager<NGridType>::end(); ) - { - NGridType *grid = i->getSource(); - GridInfo *info = i->getSource()->getGridInfoRef(); - ++i; // The update might delete the map and we need the next map before the iterator gets invalid - assert(grid->GetGridState() >= 0 && grid->GetGridState() < MAX_GRID_STATE); - si_GridStates[grid->GetGridState()]->Update(*this, *grid, *info, grid->getX(), grid->getY(), t_diff); - } - } - ///- Process necessary scripts if (!m_scriptSchedule.empty()) { @@ -733,6 +716,8 @@ void Map::Update(const uint32 &t_diff) ScriptsProcess(); i_scriptLock = false; } + + MoveAllCreaturesInMoveList(); } void Map::Remove(Player *player, bool remove) @@ -2111,11 +2096,24 @@ inline void Map::setNGrid(NGridType *grid, uint32 x, uint32 y) i_grids[x][y] = grid; } -//void Map::DoDelayedMovesAndRemoves() -//{ - //MoveAllCreaturesInMoveList(); - //RemoveAllObjectsInRemoveList(); -//} +void Map::DelayedUpdate(const uint32 t_diff) +{ + RemoveAllObjectsInRemoveList(); + + // Don't unload grids if it's battleground, since we may have manually added GOs,creatures, those doesn't load from DB at grid re-load ! + // This isn't really bother us, since as soon as we have instanced BG-s, the whole map unloads as the BG gets ended + if (!IsBattleGroundOrArena()) + { + for (GridRefManager<NGridType>::iterator i = GridRefManager<NGridType>::begin(); i != GridRefManager<NGridType>::end(); ) + { + NGridType *grid = i->getSource(); + GridInfo *info = i->getSource()->getGridInfoRef(); + ++i; // The update might delete the map and we need the next map before the iterator gets invalid + assert(grid->GetGridState() >= 0 && grid->GetGridState() < MAX_GRID_STATE); + si_GridStates[grid->GetGridState()]->Update(*this, *grid, *info, grid->getX(), grid->getY(), t_diff); + } + } +} void Map::AddObjectToRemoveList(WorldObject *obj) { diff --git a/src/game/Map.h b/src/game/Map.h index e9909b122a3..2ef300a4af6 100644 --- a/src/game/Map.h +++ b/src/game/Map.h @@ -347,9 +347,9 @@ class MANGOS_DLL_SPEC Map : public GridRefManager<NGridType>, public MaNGOS::Obj GetZoneAndAreaIdByAreaFlag(zoneid,areaid,GetAreaFlag(x,y,z),GetId()); } - virtual void MoveAllCreaturesInMoveList(); - virtual void RemoveAllObjectsInRemoveList(); - virtual void RelocationNotify(); + void MoveAllCreaturesInMoveList(); + void RemoveAllObjectsInRemoveList(); + void RelocationNotify(); virtual void RemoveAllPlayers(); bool CreatureRespawnRelocation(Creature *c); // used only in MoveAllCreaturesInMoveList and ObjectGridUnloader @@ -384,7 +384,7 @@ class MANGOS_DLL_SPEC Map : public GridRefManager<NGridType>, public MaNGOS::Obj void AddObjectToRemoveList(WorldObject *obj); void AddObjectToSwitchList(WorldObject *obj, bool on); - //void DoDelayedMovesAndRemoves(); + virtual void DelayedUpdate(const uint32 diff); virtual bool RemoveBones(uint64 guid, float x, float y); diff --git a/src/game/MapInstanced.cpp b/src/game/MapInstanced.cpp index e423abbad31..d06d2b9b677 100644 --- a/src/game/MapInstanced.cpp +++ b/src/game/MapInstanced.cpp @@ -60,31 +60,21 @@ void MapInstanced::Update(const uint32& t) } } -void MapInstanced::MoveAllCreaturesInMoveList() +void MapInstanced::DelayedUpdate(const uint32 diff) { for (InstancedMaps::iterator i = m_InstancedMaps.begin(); i != m_InstancedMaps.end(); ++i) - { - i->second->MoveAllCreaturesInMoveList(); - } + i->second->DelayedUpdate(diff); - Map::MoveAllCreaturesInMoveList(); -} - -void MapInstanced::RemoveAllObjectsInRemoveList() -{ - for (InstancedMaps::iterator i = m_InstancedMaps.begin(); i != m_InstancedMaps.end(); ++i) - { - i->second->RemoveAllObjectsInRemoveList(); - } - - Map::RemoveAllObjectsInRemoveList(); + Map::DelayedUpdate(diff); // this may be removed } +/* void MapInstanced::RelocationNotify() { for (InstancedMaps::iterator i = m_InstancedMaps.begin(); i != m_InstancedMaps.end(); ++i) i->second->RelocationNotify(); } +*/ bool MapInstanced::RemoveBones(uint64 guid, float x, float y) { diff --git a/src/game/MapInstanced.h b/src/game/MapInstanced.h index 851fe8942a0..d6b2091a8d8 100644 --- a/src/game/MapInstanced.h +++ b/src/game/MapInstanced.h @@ -35,9 +35,8 @@ class TRINITY_DLL_DECL MapInstanced : public Map // functions overwrite Map versions void Update(const uint32&); - void MoveAllCreaturesInMoveList(); - void RemoveAllObjectsInRemoveList(); - void RelocationNotify(); + void DelayedUpdate(const uint32 diff); + //void RelocationNotify(); bool RemoveBones(uint64 guid, float x, float y); void UnloadAll(); bool CanEnter(Player* player); diff --git a/src/game/MapManager.cpp b/src/game/MapManager.cpp index 74bfb5764ac..93f3db814f3 100644 --- a/src/game/MapManager.cpp +++ b/src/game/MapManager.cpp @@ -278,6 +278,9 @@ MapManager::Update(uint32 diff) } #endif + for(MapMapType::iterator iter = i_maps.begin(); iter != i_maps.end(); ++iter) + iter->second->DelayedUpdate(i_timer.GetCurrent()); + ObjectAccessor::Instance().Update(i_timer.GetCurrent()); sWorld.RecordTimeDiff("UpdateObjectAccessor"); for (TransportSet::iterator iter = m_Transports.begin(); iter != m_Transports.end(); ++iter) |