From 031df598ab444ae4ed3d3d66996168d3577fb29d Mon Sep 17 00:00:00 2001 From: megamage Date: Tue, 31 Mar 2009 09:18:39 -0600 Subject: *Try to fix crash. --HG-- branch : trunk --- src/game/GameObject.cpp | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) (limited to 'src/game/GameObject.cpp') diff --git a/src/game/GameObject.cpp b/src/game/GameObject.cpp index eb0dd10b7d4..5c945000579 100644 --- a/src/game/GameObject.cpp +++ b/src/game/GameObject.cpp @@ -63,7 +63,7 @@ GameObject::GameObject() : WorldObject() 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 { // Possible crash at access to deleted GO in Unit::m_gameobj uint64 owner_guid = GetOwnerGUID(); @@ -75,7 +75,7 @@ GameObject::~GameObject() else if(!IS_PLAYER_GUID(owner_guid)) sLog.outError("Delete GameObject (GUID: %u Entry: %u ) that have references in not found creature %u GO list. Crash possible later.",GetGUIDLow(),GetGOInfo()->id,GUID_LOPART(owner_guid)); } - } + }*/ } void GameObject::AddToWorld() @@ -93,6 +93,15 @@ void GameObject::RemoveFromWorld() ///- Remove the gameobject from the accessor if(IsInWorld()) { + // Possible crash at access to deleted GO in Unit::m_gameobj + if(uint64 owner_guid = GetOwnerGUID()) + { + Unit* owner = ObjectAccessor::GetUnit(*this,owner_guid); + if(owner) + owner->RemoveGameObject(this,false); + else if(!IS_PLAYER_GUID(owner_guid)) + sLog.outError("Delete GameObject (GUID: %u Entry: %u ) that have references in not found creature %u GO list. Crash possible later.",GetGUIDLow(),GetGOInfo()->id,GUID_LOPART(owner_guid)); + } WorldObject::RemoveFromWorld(); ObjectAccessor::Instance().RemoveObject(this); } -- cgit v1.2.3