diff options
author | Meji <alvaro.megias@outlook.com> | 2024-08-30 18:11:07 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-08-30 18:11:07 +0200 |
commit | efa76de54011d40d69412d2af23cb071ed352688 (patch) | |
tree | 8a02bf7b0aec70912f33ffd1b380c11adea0854e /src/server/game/Globals/ObjectMgr.cpp | |
parent | f213a580540bfc1ec3a7263782aa64d317afc4ce (diff) |
Core/PacketIO: Implemented UIMap questlines (#30030)
Diffstat (limited to 'src/server/game/Globals/ObjectMgr.cpp')
-rw-r--r-- | src/server/game/Globals/ObjectMgr.cpp | 106 |
1 files changed, 102 insertions, 4 deletions
diff --git a/src/server/game/Globals/ObjectMgr.cpp b/src/server/game/Globals/ObjectMgr.cpp index a684806b88c..fca4e4ff71b 100644 --- a/src/server/game/Globals/ObjectMgr.cpp +++ b/src/server/game/Globals/ObjectMgr.cpp @@ -3518,7 +3518,7 @@ void ObjectMgr::LoadVehicleAccessories() if (!result) { - TC_LOG_INFO("server.loading", ">> Loaded 0 Vehicle Accessories in {} ms", GetMSTimeDiffToNow(oldMSTime)); + TC_LOG_INFO("server.loading", ">> Loaded 0 vehicle accessories. DB table `vehicle_accessory` is empty."); return; } @@ -11060,8 +11060,6 @@ void ObjectMgr::LoadSceneTemplates() return; } - uint32 count = 0; - do { Field* fields = templates->Fetch(); @@ -11076,7 +11074,7 @@ void ObjectMgr::LoadSceneTemplates() } while (templates->NextRow()); - TC_LOG_INFO("server.loading", ">> Loaded {} scene templates in {} ms.", count, GetMSTimeDiffToNow(oldMSTime)); + TC_LOG_INFO("server.loading", ">> Loaded {} scene templates in {} ms.", _sceneTemplateStore.size(), GetMSTimeDiffToNow(oldMSTime)); } void ObjectMgr::LoadPlayerChoices() @@ -11544,6 +11542,106 @@ void ObjectMgr::LoadPlayerChoicesLocale() } } +void ObjectMgr::LoadUiMapQuestLines() +{ + uint32 oldMSTime = getMSTime(); + + // need for reload case + _uiMapQuestLinesStore.clear(); + + // 0 1 + QueryResult result = WorldDatabase.Query("SELECT UiMapId, QuestLineId FROM ui_map_quest_line"); + + if (!result) + { + TC_LOG_INFO("server.loading", ">> Loaded 0 questlines for UIMaps. DB table `ui_map_quest_line` is empty!"); + return; + } + + uint32 count = 0; + + do + { + Field* fields = result->Fetch(); + + uint32 uiMapId = fields[0].GetUInt32(); + uint32 questLineId = fields[1].GetUInt32(); + + if (!sUiMapStore.HasRecord(uiMapId)) + { + TC_LOG_ERROR("sql.sql", "Table `ui_map_quest_line` references non-existing UIMap {}, skipped", uiMapId); + continue; + } + + if (!sDB2Manager.GetQuestsForQuestLine(questLineId)) + { + TC_LOG_ERROR("sql.sql", "Table `ui_map_quest_line` references empty or non-existing questline {}, skipped", questLineId); + continue; + } + + _uiMapQuestLinesStore[uiMapId].push_back(questLineId); + ++count; + + } while (result->NextRow()); + + TC_LOG_INFO("server.loading", ">> Loaded {} UiMap questlines definitions in {} ms", count, GetMSTimeDiffToNow(oldMSTime)); +} + +std::vector<uint32> const* ObjectMgr::GetUiMapQuestLinesList(uint32 uiMapId) const +{ + return Trinity::Containers::MapGetValuePtr(_uiMapQuestLinesStore, uiMapId); +} + +void ObjectMgr::LoadUiMapQuests() +{ + uint32 oldMSTime = getMSTime(); + + // need for reload case + _uiMapQuestsStore.clear(); + + // 0 1 + QueryResult result = WorldDatabase.Query("SELECT UiMapId, QuestId FROM ui_map_quest"); + + if (!result) + { + TC_LOG_INFO("server.loading", ">> Loaded 0 quests for UIMaps. DB table `ui_map_quest` is empty!"); + return; + } + + uint32 count = 0; + + do + { + Field* fields = result->Fetch(); + + uint32 uiMapId = fields[0].GetUInt32(); + uint32 questId = fields[1].GetUInt32(); + + if (!sUiMapStore.HasRecord(uiMapId)) + { + TC_LOG_ERROR("sql.sql", "Table `ui_map_quest` references non-existing UIMap {}, skipped", uiMapId); + continue; + } + + if (!GetQuestTemplate(questId)) + { + TC_LOG_ERROR("sql.sql", "Table `ui_map_quest` references non-existing quest {}, skipped", questId); + continue; + } + + _uiMapQuestsStore[uiMapId].push_back(questId); + ++count; + + } while (result->NextRow()); + + TC_LOG_INFO("server.loading", ">> Loaded {} UiMap quests definitions in {} ms", count, GetMSTimeDiffToNow(oldMSTime)); +} + +std::vector<uint32> const* ObjectMgr::GetUiMapQuestsList(uint32 uiMapId) const +{ + return Trinity::Containers::MapGetValuePtr(_uiMapQuestsStore, uiMapId); +} + void ObjectMgr::LoadJumpChargeParams() { uint32 oldMSTime = getMSTime(); |