aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorQAston <none@none>2009-07-10 15:28:10 +0200
committerQAston <none@none>2009-07-10 15:28:10 +0200
commit83f74b5e469b14171d1ec8618f8dac512ff8452f (patch)
tree63c0fa2e2fa8acd83cd8900b44a760c29a0bb647 /src
parent73fb97adb0ae0f6262012c1ad2ba157829aebd40 (diff)
*Prevent overriding owners for gameobject.
--HG-- branch : trunk
Diffstat (limited to 'src')
-rw-r--r--src/game/GameObject.h8
1 files changed, 8 insertions, 0 deletions
diff --git a/src/game/GameObject.h b/src/game/GameObject.h
index 61df6e0e42f..0d5718a49ff 100644
--- a/src/game/GameObject.h
+++ b/src/game/GameObject.h
@@ -501,6 +501,14 @@ class TRINITY_DLL_SPEC GameObject : public WorldObject
void SetOwnerGUID(uint64 owner)
{
+ // Owner already found and different than expected owner - remove object from old owner
+ if (owner && GetOwnerGUID() && GetOwnerGUID() != owner)
+ {
+ if (Unit* owner = GetOwner())
+ owner->RemoveGameObject(this, false);
+ else
+ assert(false);
+ }
m_spawnedByDefault = false; // all object with owner is despawned after delay
SetUInt64Value(OBJECT_FIELD_CREATED_BY, owner);
}