aboutsummaryrefslogtreecommitdiff
path: root/src/server/game/Globals/ObjectMgr.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/server/game/Globals/ObjectMgr.cpp')
-rw-r--r--src/server/game/Globals/ObjectMgr.cpp30
1 files changed, 26 insertions, 4 deletions
diff --git a/src/server/game/Globals/ObjectMgr.cpp b/src/server/game/Globals/ObjectMgr.cpp
index 8c14a95a2d2..78540a5c6eb 100644
--- a/src/server/game/Globals/ObjectMgr.cpp
+++ b/src/server/game/Globals/ObjectMgr.cpp
@@ -393,8 +393,6 @@ void ObjectMgr::LoadCreatureTemplates()
// We load the creature models after loading but before checking
LoadCreatureTemplateModels();
- LoadCreatureSummonedData();
-
// Checking needs to be done after loading because of the difficulty self referencing
for (auto const& ctPair : _creatureTemplateStore)
CheckCreatureTemplate(&ctPair.second);
@@ -676,8 +674,8 @@ void ObjectMgr::LoadCreatureSummonedData()
{
uint32 oldMSTime = getMSTime();
- // 0 1 2 3
- QueryResult result = WorldDatabase.Query("SELECT CreatureID, CreatureIDVisibleToSummoner, GroundMountDisplayID, FlyingMountDisplayID FROM creature_summoned_data");
+ // 0 1 2 3 4
+ QueryResult result = WorldDatabase.Query("SELECT CreatureID, CreatureIDVisibleToSummoner, GroundMountDisplayID, FlyingMountDisplayID, DespawnOnQuestsRemoved FROM creature_summoned_data");
if (!result)
{
@@ -731,6 +729,30 @@ void ObjectMgr::LoadCreatureSummonedData()
}
}
+ if (!fields[4].IsNull())
+ {
+ std::vector<uint32> questList;
+ for (std::string_view questStr : Trinity::Tokenize(fields[4].GetStringView(), ',', false))
+ {
+ Optional<uint32> questId = Trinity::StringTo<uint32>(questStr);
+ if (!questId)
+ continue;
+
+ Quest const* quest = GetQuestTemplate(*questId);
+ if (!quest)
+ {
+ TC_LOG_ERROR("sql.sql", "Table `creature_summoned_data` references non-existing quest {} in DespawnOnQuestsRemoved for creature {}, skipping",
+ *questId, creatureId);
+ continue;
+ }
+
+ questList.push_back(*questId);
+ }
+
+ if (!questList.empty())
+ summonedData.DespawnOnQuestsRemoved = std::move(questList);
+ }
+
} while (result->NextRow());
TC_LOG_INFO("server.loading", ">> Loaded {} creature summoned data definitions in {} ms", _creatureSummonedDataStore.size(), GetMSTimeDiffToNow(oldMSTime));