diff options
Diffstat (limited to 'src/server/game/Globals/ObjectMgr.cpp')
-rw-r--r-- | src/server/game/Globals/ObjectMgr.cpp | 59 |
1 files changed, 52 insertions, 7 deletions
diff --git a/src/server/game/Globals/ObjectMgr.cpp b/src/server/game/Globals/ObjectMgr.cpp index b61f8c7e4b5..0c4ca35be92 100644 --- a/src/server/game/Globals/ObjectMgr.cpp +++ b/src/server/game/Globals/ObjectMgr.cpp @@ -4482,18 +4482,21 @@ void ObjectMgr::BuildPlayerLevelInfo(uint8 race, uint8 _class, uint8 level, Play std::vector<uint32> const* ObjectMgr::GetCreatureQuestItemList(uint32 creatureEntry, Difficulty difficulty) const { - CreatureQuestItemMap::const_iterator itr = _creatureQuestItemStore.find(std::make_pair(creatureEntry, difficulty)); - if (itr != _creatureQuestItemStore.end()) - return &itr->second; + if (std::vector<uint32> const* items = Trinity::Containers::MapGetValuePtr(_creatureQuestItemStore, { creatureEntry, difficulty })) + return items; // If there is no data for the difficulty, try to get data for the fallback difficulty - DifficultyEntry const* difficultyEntry = sDifficultyStore.LookupEntry(difficulty); - if (difficultyEntry) + if (DifficultyEntry const* difficultyEntry = sDifficultyStore.LookupEntry(difficulty)) return GetCreatureQuestItemList(creatureEntry, Difficulty(difficultyEntry->FallbackDifficultyID)); return nullptr; } +std::vector<int32> const* ObjectMgr::GetCreatureQuestCurrencyList(uint32 creatureId) const +{ + return Trinity::Containers::MapGetValuePtr(_creatureQuestCurrenciesStore, creatureId); +} + void ObjectMgr::LoadQuests() { uint32 oldMSTime = getMSTime(); @@ -10744,14 +10747,14 @@ void ObjectMgr::LoadCreatureQuestItems() { TC_LOG_ERROR("sql.sql", "Table `creature_questitem` has data for nonexistent creature (entry: {}, difficulty: {}, idx: {}), skipped", entry, difficulty, idx); continue; - }; + } ItemEntry const* db2Data = sItemStore.LookupEntry(item); if (!db2Data) { TC_LOG_ERROR("sql.sql", "Table `creature_questitem` has nonexistent item (ID: {}) in creature (entry: {}, difficulty: {}, idx: {}), skipped", item, entry, difficulty, idx); continue; - }; + } _creatureQuestItemStore[std::make_pair(entry, difficulty)].push_back(item); @@ -10762,6 +10765,48 @@ void ObjectMgr::LoadCreatureQuestItems() TC_LOG_INFO("server.loading", ">> Loaded {} creature quest items in {} ms", count, GetMSTimeDiffToNow(oldMSTime)); } +void ObjectMgr::LoadCreatureQuestCurrencies() +{ + uint32 oldMSTime = getMSTime(); + + // 0 1 + QueryResult result = WorldDatabase.Query("SELECT CreatureId, CurrencyId FROM creature_quest_currency ORDER BY CreatureId, CurrencyId ASC"); + + if (!result) + { + TC_LOG_INFO("server.loading", ">> Loaded 0 creature quest currencies. DB table `creature_quest_currency` is empty."); + return; + } + + uint32 count = 0; + do + { + Field* fields = result->Fetch(); + + uint32 entry = fields[0].GetUInt32(); + int32 currency = fields[1].GetInt32(); + + if (!GetCreatureTemplate(entry)) + { + TC_LOG_ERROR("sql.sql", "Table `creature_quest_currency` has data for nonexistent creature (entry: {}, currency: {}), skipped", entry, currency); + continue; + } + + if (!sCurrencyTypesStore.HasRecord(currency)) + { + TC_LOG_ERROR("sql.sql", "Table `creature_quest_currency` has nonexistent currency (ID: {}) in creature (entry: {}, currency: {}), skipped", currency, entry, currency); + continue; + } + + _creatureQuestCurrenciesStore[entry].push_back(currency); + + ++count; + } + while (result->NextRow()); + + TC_LOG_INFO("server.loading", ">> Loaded {} creature quest currencies in {} ms", count, GetMSTimeDiffToNow(oldMSTime)); +} + void ObjectMgr::InitializeQueriesData(QueryDataGroup mask) { uint32 oldMSTime = getMSTime(); |