Skip to content

Commit 5655aa4

Browse files
mdX7Shauren
authored andcommitted
Core/Entities: Added possibility to inherit StringIds from other entities (#29908)
* also implicitly do so for personal summons (cherry picked from commit 88bbd27f8d007dca17bb0d244fcf7e753506734e)
1 parent d98bb5f commit 5655aa4

File tree

4 files changed

+20
-0
lines changed

4 files changed

+20
-0
lines changed

src/server/game/Entities/Creature/Creature.cpp

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2776,6 +2776,15 @@ uint32 Creature::GetScriptId() const
27762776
return ASSERT_NOTNULL(sObjectMgr->GetCreatureTemplate(GetEntry()))->ScriptID;
27772777
}
27782778

2779+
void Creature::InheritStringIds(Creature const* parent)
2780+
{
2781+
// copy references to stringIds from template and spawn
2782+
m_stringIds = parent->m_stringIds;
2783+
2784+
// then copy script stringId, not just its reference
2785+
SetScriptStringId(std::string(parent->GetStringId(StringIdType::Script)));
2786+
}
2787+
27792788
bool Creature::HasStringId(std::string_view id) const
27802789
{
27812790
return std::find(m_stringIds.begin(), m_stringIds.end(), id) != m_stringIds.end();

src/server/game/Entities/Creature/Creature.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -198,6 +198,7 @@ class TC_GAME_API Creature : public Unit, public GridObject<Creature>, public Ma
198198
std::string const& GetAIName() const;
199199
std::string GetScriptName() const;
200200
uint32 GetScriptId() const;
201+
void InheritStringIds(Creature const* parent);
201202
bool HasStringId(std::string_view id) const;
202203
void SetScriptStringId(std::string id);
203204
std::array<std::string_view, 3> const& GetStringIds() const { return m_stringIds; }

src/server/game/Entities/GameObject/GameObject.cpp

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2275,6 +2275,15 @@ uint32 GameObject::GetScriptId() const
22752275
return GetGOInfo()->ScriptId;
22762276
}
22772277

2278+
void GameObject::InheritStringIds(GameObject const* parent)
2279+
{
2280+
// copy references to stringIds from template and spawn
2281+
m_stringIds = parent->m_stringIds;
2282+
2283+
// then copy script stringId, not just its reference
2284+
SetScriptStringId(std::string(parent->GetStringId(StringIdType::Script)));
2285+
}
2286+
22782287
bool GameObject::HasStringId(std::string_view id) const
22792288
{
22802289
return std::find(m_stringIds.begin(), m_stringIds.end(), id) != m_stringIds.end();

src/server/game/Entities/GameObject/GameObject.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -274,6 +274,7 @@ class TC_GAME_API GameObject : public WorldObject, public GridObject<GameObject>
274274
uint32 GetScriptId() const;
275275
GameObjectAI* AI() const { return m_AI; }
276276

277+
void InheritStringIds(GameObject const* parent);
277278
bool HasStringId(std::string_view id) const;
278279
void SetScriptStringId(std::string id);
279280
std::array<std::string_view, 3> const& GetStringIds() const { return m_stringIds; }

0 commit comments

Comments
 (0)