From 0188d4cd73a37105d84b585dbe7bfe03f8e68777 Mon Sep 17 00:00:00 2001 From: killerwife Date: Tue, 21 Nov 2023 17:30:36 +0100 Subject: [PATCH] StringId: Fix string id objects not being cleared on despawn --- src/game/Entities/Object.cpp | 13 ++++++++----- src/game/Entities/Unit.cpp | 2 +- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/src/game/Entities/Object.cpp b/src/game/Entities/Object.cpp index 7f80ae23e2..546af8321f 100644 --- a/src/game/Entities/Object.cpp +++ b/src/game/Entities/Object.cpp @@ -2037,12 +2037,15 @@ void WorldObject::AddToWorld() void WorldObject::RemoveFromWorld() { - if (m_isOnEventNotified) - m_currMap->RemoveFromOnEventNotified(this); + if (IsInWorld()) + { + if (m_isOnEventNotified) + m_currMap->RemoveFromOnEventNotified(this); - if (!m_stringIds.empty()) - for (uint32 stringId : m_stringIds) - m_currMap->RemoveStringIdObject(stringId, this); + if (!m_stringIds.empty()) + for (uint32 stringId : m_stringIds) + m_currMap->RemoveStringIdObject(stringId, this); + } Object::RemoveFromWorld(); } diff --git a/src/game/Entities/Unit.cpp b/src/game/Entities/Unit.cpp index 294994bfc4..ca7118ada3 100644 --- a/src/game/Entities/Unit.cpp +++ b/src/game/Entities/Unit.cpp @@ -9778,7 +9778,7 @@ void Unit::RemoveFromWorld() m_FollowingRefManager.clearReferences(); } - Object::RemoveFromWorld(); + WorldObject::RemoveFromWorld(); } void Unit::CleanupsBeforeDelete()