Core/GameObject: Remove linked traps when the main GameObject is remo… (#24480)

* Core/GameObject: Remove linked traps when the main GameObject is removed from from the world

* Indentation

(cherry picked from commit 7e9bc9599b)
This commit is contained in:
Eridium
2020-04-26 21:25:54 +02:00
committed by Shauren
parent 5ce8c26914
commit 88b898b92c

View File

@@ -247,6 +247,10 @@ void GameObject::RemoveFromWorld()
if (GetMap()->ContainsGameObjectModel(*m_model))
GetMap()->RemoveGameObjectModel(*m_model);
// If linked trap exists, despawn it
if (GameObject* linkedTrap = GetLinkedTrap())
linkedTrap->DespawnOrUnsummon();
WorldObject::RemoveFromWorld();
if (m_spawnId)
@@ -1030,10 +1034,6 @@ void GameObject::DespawnOrUnsummon(Milliseconds delay, Seconds forceRespawnTime)
void GameObject::Delete()
{
// If nearby linked trap exists, despawn it
if (GameObject* linkedTrap = GetLinkedTrap())
linkedTrap->DespawnOrUnsummon();
SetLootState(GO_NOT_READY);
RemoveFromOwner();