aboutsummaryrefslogtreecommitdiff
path: root/src/game/GameObject.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/game/GameObject.cpp')
-rw-r--r--src/game/GameObject.cpp9
1 files changed, 5 insertions, 4 deletions
diff --git a/src/game/GameObject.cpp b/src/game/GameObject.cpp
index e6ff16f251c..f934d3d1fe7 100644
--- a/src/game/GameObject.cpp
+++ b/src/game/GameObject.cpp
@@ -123,8 +123,7 @@ void GameObject::RemoveFromWorld()
// 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)
+ if(Unit * owner = GetOwner(false))
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));
@@ -707,9 +706,11 @@ bool GameObject::IsTransport() const
return gInfo->type == GAMEOBJECT_TYPE_TRANSPORT || gInfo->type == GAMEOBJECT_TYPE_MO_TRANSPORT;
}
-Unit* GameObject::GetOwner() const
+Unit* GameObject::GetOwner(bool inWorld) const
{
- return ObjectAccessor::GetUnit(*this, GetOwnerGUID());
+ if (inWorld)
+ return ObjectAccessor::GetUnit(*this, GetOwnerGUID());
+ return ObjectAccessor::GetUnitInOrOutOfWorld(*this, GetOwnerGUID());
}
void GameObject::SaveRespawnTime()