*Delete object after map update. This will make mtmap safer.

--HG--
branch : trunk
This commit is contained in:
megamage
2009-08-25 15:12:22 -05:00
parent df4fe8c4dc
commit 1f88411ccc
5 changed files with 41 additions and 51 deletions
+27 -29
View File
@@ -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)
{
+4 -4
View File
@@ -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);
+5 -15
View File
@@ -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)
{
+2 -3
View File
@@ -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);
+3
View File
@@ -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)