*ResetMap for worldobjects when map is deleted.

--HG--
branch : trunk
This commit is contained in:
megamage
2009-08-11 16:33:33 -05:00
parent 9403ff03e7
commit 962b88a381
4 changed files with 29 additions and 5 deletions
+5 -1
View File
@@ -60,6 +60,9 @@ Map::~Map()
{ {
UnloadAll(); UnloadAll();
while(!i_worldObjects.empty())
(*(i_worldObjects.begin()))->ResetMap();
if(!m_scriptSchedule.empty()) if(!m_scriptSchedule.empty())
sWorld.DecreaseScheduledScriptCount(m_scriptSchedule.size()); sWorld.DecreaseScheduledScriptCount(m_scriptSchedule.size());
} }
@@ -581,8 +584,9 @@ void Map::AddUnitToNotify(Unit* u)
} }
} }
void Map::RemoveUnitFromNotify(Unit *unit, int32 slot) void Map::RemoveUnitFromNotify(Unit *unit)
{ {
int32 slot = unit->m_NotifyListPos;
if(i_lock) if(i_lock)
{ {
if(slot < i_unitsToNotifyBacklog.size() && i_unitsToNotifyBacklog[slot] == unit) if(slot < i_unitsToNotifyBacklog.size() && i_unitsToNotifyBacklog[slot] == unit)
+4 -1
View File
@@ -404,7 +404,9 @@ class MANGOS_DLL_SPEC Map : public GridRefManager<NGridType>, public MaNGOS::Obj
bool ActiveObjectsNearGrid(uint32 x, uint32 y) const; bool ActiveObjectsNearGrid(uint32 x, uint32 y) const;
void AddUnitToNotify(Unit* unit); void AddUnitToNotify(Unit* unit);
void RemoveUnitFromNotify(Unit *unit, int32 slot); void RemoveUnitFromNotify(Unit *unit);
void AddWorldObject(WorldObject *obj) { i_worldObjects.insert(obj); }
void RemoveWorldObject(WorldObject *obj) { i_worldObjects.erase(obj); }
void SendToPlayers(WorldPacket const* data) const; void SendToPlayers(WorldPacket const* data) const;
@@ -527,6 +529,7 @@ class MANGOS_DLL_SPEC Map : public GridRefManager<NGridType>, public MaNGOS::Obj
std::vector<Unit*> i_unitsToNotify; std::vector<Unit*> i_unitsToNotify;
std::set<WorldObject *> i_objectsToRemove; std::set<WorldObject *> i_objectsToRemove;
std::map<WorldObject*, bool> i_objectsToSwitch; std::map<WorldObject*, bool> i_objectsToSwitch;
std::set<WorldObject*> i_worldObjects;
std::multimap<time_t, ScriptAction> m_scriptSchedule; std::multimap<time_t, ScriptAction> m_scriptSchedule;
// Type specific code for add/remove to/from grid // Type specific code for add/remove to/from grid
+19 -2
View File
@@ -80,6 +80,18 @@ Object::Object( ) : m_PackGUID(sizeof(uint64)+1)
m_PackGUID.appendPackGUID(0); m_PackGUID.appendPackGUID(0);
} }
/*
WorldObject::~WorldObject()
{
if(m_currMap)
{
sLog.outCrash("Object::~Object - guid="UI64FMTD", typeid=%d, entry=%u deleted but still in map!!", GetGUID(), GetTypeId(), GetEntry());
assert(false);
ResetMap();
}
}
*/
Object::~Object( ) Object::~Object( )
{ {
if(IsInWorld()) if(IsInWorld())
@@ -1692,14 +1704,19 @@ void WorldObject::SendObjectDeSpawnAnim(uint64 guid)
void WorldObject::SetMap(Map * map) void WorldObject::SetMap(Map * map)
{ {
ASSERT(map); ASSERT(map);
ASSERT(!IsInWorld() || GetTypeId() == TYPEID_CORPSE); //ASSERT(!IsInWorld());
ASSERT(!m_currMap);
m_currMap = map; m_currMap = map;
if(m_isWorldObject)
m_currMap->AddWorldObject(this);
} }
void WorldObject::ResetMap() void WorldObject::ResetMap()
{ {
ASSERT(m_currMap); ASSERT(m_currMap);
ASSERT(!IsInWorld() || GetTypeId() == TYPEID_CORPSE); //ASSERT(!IsInWorld() || GetTypeId() == TYPEID_CORPSE);
if(m_isWorldObject)
m_currMap->RemoveWorldObject(this);
m_currMap = NULL; m_currMap = NULL;
} }
+1 -1
View File
@@ -12389,7 +12389,7 @@ void Unit::RemoveFromWorld()
RemoveAllControlled(); RemoveAllControlled();
if(m_NotifyListPos >= 0) if(m_NotifyListPos >= 0)
GetMap()->RemoveUnitFromNotify(this, m_NotifyListPos); GetMap()->RemoveUnitFromNotify(this);
if(GetCharmerGUID()) if(GetCharmerGUID())
{ {