aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormegamage <none@none>2009-07-01 18:23:36 -0500
committermegamage <none@none>2009-07-01 18:23:36 -0500
commit111dac5f94eac3fe26da2107842dea4e1aacd660 (patch)
tree94749b7199a4f0bb2f2826824261e49a85f84082
parent9a2588a454af73fb1f6c456275ba07e6acc24d11 (diff)
[8102] Simplify code base at new root method WorldObject::CleanupsBeforeDelete Author: VladimirMangos
* Call it from Map::AddObjectToRemoveList and remove now not needed explcit calls * Create Gameobject version to make GO with owner more safe for remove --HG-- branch : trunk
-rw-r--r--src/game/BattleGround.cpp2
-rw-r--r--src/game/GameEventMgr.cpp3
-rw-r--r--src/game/GameObject.cpp18
-rw-r--r--src/game/GameObject.h1
-rw-r--r--src/game/Level2.cpp2
-rw-r--r--src/game/Map.cpp3
-rw-r--r--src/game/Object.cpp4
-rw-r--r--src/game/Object.h2
-rw-r--r--src/game/OutdoorPvP.cpp1
-rw-r--r--src/game/Player.cpp1
-rw-r--r--src/game/PoolHandler.cpp3
-rw-r--r--src/game/TemporarySummon.cpp1
-rw-r--r--src/game/Totem.cpp1
-rw-r--r--src/game/Vehicle.cpp1
14 files changed, 20 insertions, 23 deletions
diff --git a/src/game/BattleGround.cpp b/src/game/BattleGround.cpp
index 71062657c0b..8465e32f799 100644
--- a/src/game/BattleGround.cpp
+++ b/src/game/BattleGround.cpp
@@ -1609,8 +1609,6 @@ bool BattleGround::DelCreature(uint32 type)
sLog.outError("Can't find creature guid: %u",GUID_LOPART(m_BgCreatures[type]));
return false;
}
- //TODO: only delete creature after not in combat
- cr->CleanupsBeforeDelete();
cr->AddObjectToRemoveList();
m_BgCreatures[type] = 0;
return true;
diff --git a/src/game/GameEventMgr.cpp b/src/game/GameEventMgr.cpp
index 0984c896eac..828e17b7cf9 100644
--- a/src/game/GameEventMgr.cpp
+++ b/src/game/GameEventMgr.cpp
@@ -1313,10 +1313,7 @@ void GameEventMgr::GameEventUnspawn(int16 event_id)
objmgr.RemoveCreatureFromGrid(*itr, data);
if( Creature* pCreature = ObjectAccessor::Instance().GetObjectInWorld(MAKE_NEW_GUID(*itr, data->id, HIGHGUID_UNIT), (Creature*)NULL) )
- {
- pCreature->CleanupsBeforeDelete();
pCreature->AddObjectToRemoveList();
- }
}
}
diff --git a/src/game/GameObject.cpp b/src/game/GameObject.cpp
index d6aa162b50a..85a86f18cdf 100644
--- a/src/game/GameObject.cpp
+++ b/src/game/GameObject.cpp
@@ -65,14 +65,18 @@ GameObject::GameObject() : WorldObject(), m_goValue(new GameObjectValue)
GameObject::~GameObject()
{
- /*if(m_uint32Values) // field array can be not exist if GameOBject not loaded
+ //if(m_uint32Values) // field array can be not exist if GameOBject not loaded
+ // CleanupsBeforeDelete();
+}
+
+void GameObject::CleanupsBeforeDelete()
+{
+ if(m_uint32Values) // field array can be not exist if GameOBject not loaded
{
// Possible crash at access to deleted GO in Unit::m_gameobj
- uint64 owner_guid = GetOwnerGUID();
- if(owner_guid)
+ if(uint64 owner_guid = GetOwnerGUID())
{
- Unit* owner = ObjectAccessor::GetUnit(*this,owner_guid);
- if(owner)
+ if(Unit* owner = ObjectAccessor::GetUnit(*this,owner_guid))
owner->RemoveGameObject(this,false);
else
{
@@ -83,10 +87,10 @@ GameObject::~GameObject()
ownerType = "pet";
sLog.outError("Delete GameObject (GUID: %u Entry: %u SpellId %u LinkedGO %u) that lost references to owner (GUID %u Type '%s') GO list. Crash possible later.",
- GetGUIDLow(), GetGOInfo()->id, m_spellId, GetLinkedGameObjectEntry(), GUID_LOPART(owner_guid), ownerType);
+ GetGUIDLow(), GetGOInfo()->id, m_spellId, GetLinkedGameObjectEntry(), GUID_LOPART(owner_guid), ownerType);
}
}
- }*/
+ }
}
void GameObject::AddToWorld()
diff --git a/src/game/GameObject.h b/src/game/GameObject.h
index 43f8fb0ea5f..61df6e0e42f 100644
--- a/src/game/GameObject.h
+++ b/src/game/GameObject.h
@@ -488,6 +488,7 @@ class TRINITY_DLL_SPEC GameObject : public WorldObject
void AddToWorld();
void RemoveFromWorld();
+ void CleanupsBeforeDelete();
bool Create(uint32 guidlow, uint32 name_id, Map *map, uint32 phaseMask, float x, float y, float z, float ang, float rotation0, float rotation1, float rotation2, float rotation3, uint32 animprogress, GOState go_state, uint32 ArtKit = 0);
void Update(uint32 p_time);
diff --git a/src/game/Level2.cpp b/src/game/Level2.cpp
index fc7dc8b1618..75bd8357200 100644
--- a/src/game/Level2.cpp
+++ b/src/game/Level2.cpp
@@ -1377,7 +1377,6 @@ bool ChatHandler::HandleNpcDeleteCommand(const char* args)
// Delete the creature
unit->CombatStop();
unit->DeleteFromDB();
- unit->CleanupsBeforeDelete();
unit->AddObjectToRemoveList();
SendSysMessage(LANG_COMMAND_DELCREATMESSAGE);
@@ -3449,7 +3448,6 @@ bool ChatHandler::HandleWpShowCommand(const char* args)
Field *fields = result->Fetch();
uint32 guid = fields[0].GetUInt32();
Creature* pCreature = m_session->GetPlayer()->GetMap()->GetCreature(MAKE_NEW_GUID(guid,VISUAL_WAYPOINT,HIGHGUID_UNIT));
-
if(!pCreature)
{
PSendSysMessage(LANG_WAYPOINT_NOTREMOVED, guid);
diff --git a/src/game/Map.cpp b/src/game/Map.cpp
index 6dbb0e37c86..044d48cac36 100644
--- a/src/game/Map.cpp
+++ b/src/game/Map.cpp
@@ -1010,7 +1010,6 @@ void Map::MoveAllCreaturesInMoveList()
if((sLog.getLogFilter() & LOG_FILTER_CREATURE_MOVES)==0)
sLog.outDebug("Creature (GUID: %u Entry: %u ) can't be move to unloaded respawn grid.",c->GetGUIDLow(),c->GetEntry());
#endif
- c->CleanupsBeforeDelete();
AddObjectToRemoveList(c);
}
}
@@ -2151,6 +2150,8 @@ void Map::AddObjectToRemoveList(WorldObject *obj)
{
assert(obj->GetMapId()==GetId() && obj->GetInstanceId()==GetInstanceId());
+ obj->CleanupsBeforeDelete(); // remove or simplify at least cross referenced links
+
i_objectsToRemove.insert(obj);
//sLog.outDebug("Object (GUID: %u TypeId: %u ) added to removing list.",obj->GetGUIDLow(),obj->GetTypeId());
}
diff --git a/src/game/Object.cpp b/src/game/Object.cpp
index 3561621f0bd..8274797fda4 100644
--- a/src/game/Object.cpp
+++ b/src/game/Object.cpp
@@ -1096,6 +1096,10 @@ void WorldObject::setActive( bool on )
}
}
+void WorldObject::CleanupsBeforeDelete()
+{
+}
+
void WorldObject::_Create( uint32 guidlow, HighGuid guidhigh, uint32 mapid, uint32 phaseMask )
{
Object::_Create(guidlow, 0, guidhigh);
diff --git a/src/game/Object.h b/src/game/Object.h
index 8e86ff1c87b..96bd1f12d46 100644
--- a/src/game/Object.h
+++ b/src/game/Object.h
@@ -498,6 +498,8 @@ class TRINITY_DLL_SPEC WorldObject : public Object
bool HasInArc( const float arcangle, const WorldObject* obj ) const;
bool IsInBetween(const WorldObject *obj1, const WorldObject *obj2, float size = 0) const;
+ virtual void CleanupsBeforeDelete(); // used in destructor or explicitly before mass creature delete to remove cross-references to already deleted units
+
virtual void SendMessageToSet(WorldPacket *data, bool self);
virtual void SendMessageToSetInRange(WorldPacket *data, float dist, bool self);
diff --git a/src/game/OutdoorPvP.cpp b/src/game/OutdoorPvP.cpp
index fd1cf87e6d6..3e0239935aa 100644
--- a/src/game/OutdoorPvP.cpp
+++ b/src/game/OutdoorPvP.cpp
@@ -116,7 +116,6 @@ bool OPvPCapturePoint::DelCreature(uint32 type)
// Don't save respawn time
cr->SetRespawnTime(0);
cr->RemoveCorpse();
- cr->CleanupsBeforeDelete();
// explicit removal from map
// beats me why this is needed, but with the recent removal "cleanup" some creatures stay in the map if "properly" deleted
// so this is a big fat workaround, if AddObjectToRemoveList and DoDelayedMovesAndRemoves worked correctly, this wouldn't be needed
diff --git a/src/game/Player.cpp b/src/game/Player.cpp
index e3c27cb7d42..946a47cf098 100644
--- a/src/game/Player.cpp
+++ b/src/game/Player.cpp
@@ -16814,7 +16814,6 @@ void Player::RemovePet(Pet* pet, PetSaveMode mode, bool returnreagent)
SetMinion(pet, false);
- pet->CleanupsBeforeDelete();
pet->AddObjectToRemoveList();
pet->m_removed = true;
diff --git a/src/game/PoolHandler.cpp b/src/game/PoolHandler.cpp
index 09a1d4293b7..dd0834b80f4 100644
--- a/src/game/PoolHandler.cpp
+++ b/src/game/PoolHandler.cpp
@@ -127,10 +127,7 @@ void PoolGroup<Creature>::Despawn1Object(uint32 guid)
objmgr.RemoveCreatureFromGrid(guid, data);
if (Creature* pCreature = ObjectAccessor::Instance().GetObjectInWorld(MAKE_NEW_GUID(guid, data->id, HIGHGUID_UNIT), (Creature*)NULL))
- {
- pCreature->CleanupsBeforeDelete();
pCreature->AddObjectToRemoveList();
- }
}
}
diff --git a/src/game/TemporarySummon.cpp b/src/game/TemporarySummon.cpp
index 724d68c568b..42cf0f4c2ef 100644
--- a/src/game/TemporarySummon.cpp
+++ b/src/game/TemporarySummon.cpp
@@ -230,7 +230,6 @@ void TempSummon::UnSummon()
if(owner && owner->GetTypeId() == TYPEID_UNIT && ((Creature*)owner)->IsAIEnabled)
((Creature*)owner)->AI()->SummonedCreatureDespawn(this);
- CleanupsBeforeDelete();
AddObjectToRemoveList();
}
diff --git a/src/game/Totem.cpp b/src/game/Totem.cpp
index 67fa0281d91..4df48fa9147 100644
--- a/src/game/Totem.cpp
+++ b/src/game/Totem.cpp
@@ -129,7 +129,6 @@ void Totem::UnSummon()
}
}
- CleanupsBeforeDelete();
AddObjectToRemoveList();
}
diff --git a/src/game/Vehicle.cpp b/src/game/Vehicle.cpp
index 54bb5275f45..8389eaf4cc9 100644
--- a/src/game/Vehicle.cpp
+++ b/src/game/Vehicle.cpp
@@ -389,7 +389,6 @@ void Vehicle::Dismiss()
RemoveAllPassengers();
SendObjectDeSpawnAnim(GetGUID());
CombatStop();
- CleanupsBeforeDelete();
AddObjectToRemoveList();
}