From 88bbd27f8d007dca17bb0d244fcf7e753506734e Mon Sep 17 00:00:00 2001 From: ModoX Date: Wed, 10 Apr 2024 20:03:14 +0200 Subject: Core/Entities: Added possibility to inherit StringIds from other entities (#29908) * also implicitly do so for personal summons --- src/server/game/Entities/GameObject/GameObject.cpp | 9 +++++++++ src/server/game/Entities/GameObject/GameObject.h | 1 + 2 files changed, 10 insertions(+) (limited to 'src/server/game/Entities/GameObject') diff --git a/src/server/game/Entities/GameObject/GameObject.cpp b/src/server/game/Entities/GameObject/GameObject.cpp index b8788e892c0..f40c86eece6 100644 --- a/src/server/game/Entities/GameObject/GameObject.cpp +++ b/src/server/game/Entities/GameObject/GameObject.cpp @@ -3497,6 +3497,15 @@ uint32 GameObject::GetScriptId() const return GetGOInfo()->ScriptId; } +void GameObject::InheritStringIds(GameObject const* parent) +{ + // copy references to stringIds from template and spawn + m_stringIds = parent->m_stringIds; + + // then copy script stringId, not just its reference + SetScriptStringId(std::string(parent->GetStringId(StringIdType::Script))); +} + bool GameObject::HasStringId(std::string_view id) const { return std::find(m_stringIds.begin(), m_stringIds.end(), id) != m_stringIds.end(); diff --git a/src/server/game/Entities/GameObject/GameObject.h b/src/server/game/Entities/GameObject/GameObject.h index 13b8afdd5ad..c194e44fa9d 100644 --- a/src/server/game/Entities/GameObject/GameObject.h +++ b/src/server/game/Entities/GameObject/GameObject.h @@ -378,6 +378,7 @@ class TC_GAME_API GameObject : public WorldObject, public GridObject uint32 GetScriptId() const; GameObjectAI* AI() const { return m_AI; } + void InheritStringIds(GameObject const* parent); bool HasStringId(std::string_view id) const; void SetScriptStringId(std::string id); std::array const& GetStringIds() const { return m_stringIds; } -- cgit v1.2.3