diff options
author | ModoX <moardox@gmail.com> | 2024-01-08 21:51:46 +0100 |
---|---|---|
committer | funjoker <funjoker109@gmail.com> | 2024-01-09 20:45:32 +0100 |
commit | 4fe41bba8e7ffaa514856c51218df26784ecb0f6 (patch) | |
tree | 70a77d4071a9536b4d8e5b272ece36f66fc280a1 /src/server/game/Globals/ObjectMgr.cpp | |
parent | 82b605645b96722b92b8200ed90503cb87bf7aa7 (diff) |
Core/Creatures: Added possibility to automatically despawn personal summons on quest remove (#29114)
(cherry picked from commit b3dce0ac08d4f740505037aff2cad7685444db15)
Diffstat (limited to 'src/server/game/Globals/ObjectMgr.cpp')
-rw-r--r-- | src/server/game/Globals/ObjectMgr.cpp | 30 |
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)); |