diff options
-rw-r--r-- | src/server/game/Entities/Creature/Creature.cpp | 9 | ||||
-rw-r--r-- | src/server/game/Entities/Creature/Creature.h | 1 | ||||
-rw-r--r-- | src/server/game/Entities/GameObject/GameObject.cpp | 9 | ||||
-rw-r--r-- | src/server/game/Entities/GameObject/GameObject.h | 1 |
4 files changed, 20 insertions, 0 deletions
diff --git a/src/server/game/Entities/Creature/Creature.cpp b/src/server/game/Entities/Creature/Creature.cpp index ee70ea61f90..79e97628aa9 100644 --- a/src/server/game/Entities/Creature/Creature.cpp +++ b/src/server/game/Entities/Creature/Creature.cpp @@ -2776,6 +2776,15 @@ uint32 Creature::GetScriptId() const return ASSERT_NOTNULL(sObjectMgr->GetCreatureTemplate(GetEntry()))->ScriptID; } +void Creature::InheritStringIds(Creature 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 Creature::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/Creature/Creature.h b/src/server/game/Entities/Creature/Creature.h index cff54558830..b2768a45643 100644 --- a/src/server/game/Entities/Creature/Creature.h +++ b/src/server/game/Entities/Creature/Creature.h @@ -198,6 +198,7 @@ class TC_GAME_API Creature : public Unit, public GridObject<Creature>, public Ma std::string const& GetAIName() const; std::string GetScriptName() const; uint32 GetScriptId() const; + void InheritStringIds(Creature const* parent); bool HasStringId(std::string_view id) const; void SetScriptStringId(std::string id); std::array<std::string_view, 3> const& GetStringIds() const { return m_stringIds; } diff --git a/src/server/game/Entities/GameObject/GameObject.cpp b/src/server/game/Entities/GameObject/GameObject.cpp index 02f25493186..2e2b11b2e62 100644 --- a/src/server/game/Entities/GameObject/GameObject.cpp +++ b/src/server/game/Entities/GameObject/GameObject.cpp @@ -2275,6 +2275,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 45601068bb4..7c412f01477 100644 --- a/src/server/game/Entities/GameObject/GameObject.h +++ b/src/server/game/Entities/GameObject/GameObject.h @@ -274,6 +274,7 @@ class TC_GAME_API GameObject : public WorldObject, public GridObject<GameObject> 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<std::string_view, 3> const& GetStringIds() const { return m_stringIds; } |