aboutsummaryrefslogtreecommitdiff
path: root/src/game/GameObject.cpp
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 /src/game/GameObject.cpp
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
Diffstat (limited to 'src/game/GameObject.cpp')
-rw-r--r--src/game/GameObject.cpp18
1 files changed, 11 insertions, 7 deletions
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()