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
This commit is contained in:
Eridium
2020-04-26 21:25:54 +02:00
committed by Ovahlord
parent e871d2f0eb
commit 2aa05b951b

View File

@@ -248,6 +248,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)
@@ -848,10 +852,6 @@ void GameObject::DespawnOrUnsummon(Milliseconds const& delay, Seconds const& for
void GameObject::Delete()
{
// If nearby linked trap exists, despawn it
if (GameObject* linkedTrap = GetLinkedTrap())
linkedTrap->DespawnOrUnsummon();
SetLootState(GO_NOT_READY);
RemoveFromOwner();