diff options
Diffstat (limited to 'src/server/game/Globals/ObjectMgr.cpp')
-rw-r--r-- | src/server/game/Globals/ObjectMgr.cpp | 236 |
1 files changed, 207 insertions, 29 deletions
diff --git a/src/server/game/Globals/ObjectMgr.cpp b/src/server/game/Globals/ObjectMgr.cpp index e4dbe60535d..e37513d0917 100644 --- a/src/server/game/Globals/ObjectMgr.cpp +++ b/src/server/game/Globals/ObjectMgr.cpp @@ -357,7 +357,8 @@ void ObjectMgr::LoadGossipMenuItemsLocales() AddLocaleString(fields[2 + 2 * (i - 1)].GetString(), locale, data.OptionText); AddLocaleString(fields[2 + 2 * (i - 1) + 1].GetString(), locale, data.BoxText); } - } while (result->NextRow()); + } + while (result->NextRow()); TC_LOG_INFO("server.loading", ">> Loaded %lu gossip_menu_option locale strings in %u ms", (unsigned long)_gossipMenuItemsLocaleStore.size(), GetMSTimeDiffToNow(oldMSTime)); } @@ -5203,17 +5204,28 @@ void ObjectMgr::LoadGossipText() { uint32 oldMSTime = getMSTime(); - QueryResult result = WorldDatabase.Query("SELECT * FROM npc_text"); + QueryResult result = WorldDatabase.Query("SELECT ID, " + "text0_0, text0_1, BroadcastTextID0, lang0, prob0, em0_0, em0_1, em0_2, em0_3, em0_4, em0_5, " + "text1_0, text1_1, BroadcastTextID1, lang1, prob1, em1_0, em1_1, em1_2, em1_3, em1_4, em1_5, " + "text2_0, text2_1, BroadcastTextID2, lang2, prob2, em2_0, em2_1, em2_2, em2_3, em2_4, em2_5, " + "text3_0, text3_1, BroadcastTextID3, lang3, prob3, em3_0, em3_1, em3_2, em3_3, em3_4, em3_5, " + "text4_0, text4_1, BroadcastTextID4, lang4, prob4, em4_0, em4_1, em4_2, em4_3, em4_4, em4_5, " + "text5_0, text5_1, BroadcastTextID5, lang5, prob5, em5_0, em5_1, em5_2, em5_3, em5_4, em5_5, " + "text6_0, text6_1, BroadcastTextID6, lang6, prob6, em6_0, em6_1, em6_2, em6_3, em6_4, em6_5, " + "text7_0, text7_1, BroadcastTextID7, lang7, prob7, em7_0, em7_1, em7_2, em7_3, em7_4, em7_5 " + "FROM npc_text"); + - int count = 0; if (!result) { - TC_LOG_INFO("server.loading", ">> Loaded %u npc texts", count); + TC_LOG_INFO("server.loading", ">> Loaded 0 npc texts, table is empty!"); return; } + _gossipTextStore.rehash(result->GetRowCount()); - int cic; + uint32 count = 0; + uint8 cic; do { @@ -5222,32 +5234,44 @@ void ObjectMgr::LoadGossipText() Field* fields = result->Fetch(); - uint32 Text_ID = fields[cic++].GetUInt32(); - if (!Text_ID) + uint32 id = fields[cic++].GetUInt32(); + if (!id) { - TC_LOG_ERROR("sql.sql", "Table `npc_text` has record wit reserved id 0, ignore."); + TC_LOG_ERROR("sql.sql", "Table `npc_text` has record with reserved id 0, ignore."); continue; } - GossipText& gText = _gossipTextStore[Text_ID]; + GossipText& gText = _gossipTextStore[id]; - for (int i = 0; i < MAX_GOSSIP_TEXT_OPTIONS; i++) + for (uint8 i = 0; i < MAX_GOSSIP_TEXT_OPTIONS; ++i) { gText.Options[i].Text_0 = fields[cic++].GetString(); gText.Options[i].Text_1 = fields[cic++].GetString(); - - gText.Options[i].BroadcastTextID = fields[cic++].GetUInt32(); // Need for correct loading order - + gText.Options[i].BroadcastTextID = fields[cic++].GetUInt32(); gText.Options[i].Language = fields[cic++].GetUInt8(); gText.Options[i].Probability = fields[cic++].GetFloat(); - for (uint8 j=0; j < MAX_GOSSIP_TEXT_EMOTES; ++j) + for (uint8 j = 0; j < MAX_GOSSIP_TEXT_EMOTES; ++j) { - gText.Options[i].Emotes[j]._Delay = fields[cic++].GetUInt16(); - gText.Options[i].Emotes[j]._Emote = fields[cic++].GetUInt16(); + gText.Options[i].Emotes[j]._Delay = fields[cic++].GetUInt16(); + gText.Options[i].Emotes[j]._Emote = fields[cic++].GetUInt16(); } } - } while (result->NextRow()); + + for (uint8 i = 0; i < MAX_GOSSIP_TEXT_OPTIONS; i++) + { + if (gText.Options[i].BroadcastTextID) + { + if (!sObjectMgr->GetBroadcastText(gText.Options[i].BroadcastTextID)) + { + TC_LOG_ERROR("sql.sql", "GossipText (Id: %u) in table `npc_text` has non-existing or incompatible BroadcastTextID%u %u.", id, i, gText.Options[i].BroadcastTextID); + gText.Options[i].BroadcastTextID = 0; + } + } + } + + } + while (result->NextRow()); TC_LOG_INFO("server.loading", ">> Loaded %u npc texts in %u ms", count, GetMSTimeDiffToNow(oldMSTime)); } @@ -8266,8 +8290,8 @@ void ObjectMgr::LoadGossipMenuItems() _gossipMenuItemsStore.clear(); QueryResult result = WorldDatabase.Query( - // 0 1 2 3 4 5 6 7 8 9 10 - "SELECT menu_id, id, option_icon, option_text, option_id, npc_option_npcflag, action_menu_id, action_poi_id, box_coded, box_money, box_text " + // 0 1 2 3 4 5 6 7 8 9 10 11 12 + "SELECT menu_id, id, option_icon, option_text, OptionBroadcastTextID, option_id, npc_option_npcflag, action_menu_id, action_poi_id, box_coded, box_money, box_text, BoxBroadcastTextID " "FROM gossip_menu_option ORDER BY menu_id, id"); if (!result) @@ -8288,29 +8312,49 @@ void ObjectMgr::LoadGossipMenuItems() gMenuItem.OptionIndex = fields[1].GetUInt16(); gMenuItem.OptionIcon = fields[2].GetUInt32(); gMenuItem.OptionText = fields[3].GetString(); - gMenuItem.OptionType = fields[4].GetUInt8(); - gMenuItem.OptionNpcflag = fields[5].GetUInt32(); - gMenuItem.ActionMenuId = fields[6].GetUInt32(); - gMenuItem.ActionPoiId = fields[7].GetUInt32(); - gMenuItem.BoxCoded = fields[8].GetBool(); - gMenuItem.BoxMoney = fields[9].GetUInt32(); - gMenuItem.BoxText = fields[10].GetString(); + gMenuItem.OptionBroadcastTextId = fields[4].GetUInt32(); + gMenuItem.OptionType = fields[5].GetUInt8(); + gMenuItem.OptionNpcflag = fields[6].GetUInt32(); + gMenuItem.ActionMenuId = fields[7].GetUInt32(); + gMenuItem.ActionPoiId = fields[8].GetUInt32(); + gMenuItem.BoxCoded = fields[9].GetBool(); + gMenuItem.BoxMoney = fields[10].GetUInt32(); + gMenuItem.BoxText = fields[11].GetString(); + gMenuItem.BoxBroadcastTextId = fields[12].GetUInt32(); if (gMenuItem.OptionIcon >= GOSSIP_ICON_MAX) { - TC_LOG_ERROR("sql.sql", "Table gossip_menu_option for menu %u, id %u has unknown icon id %u. Replacing with GOSSIP_ICON_CHAT", gMenuItem.MenuId, gMenuItem.OptionIndex, gMenuItem.OptionIcon); + TC_LOG_ERROR("sql.sql", "Table `gossip_menu_option` for menu %u, id %u has unknown icon id %u. Replacing with GOSSIP_ICON_CHAT", gMenuItem.MenuId, gMenuItem.OptionIndex, gMenuItem.OptionIcon); gMenuItem.OptionIcon = GOSSIP_ICON_CHAT; } + if (gMenuItem.OptionBroadcastTextId) + { + if (!GetBroadcastText(gMenuItem.OptionBroadcastTextId)) + { + TC_LOG_ERROR("sql.sql", "Table `gossip_menu_option` for menu %u, id %u has non-existing or incompatible OptionBroadcastTextId %u, ignoring.", gMenuItem.MenuId, gMenuItem.OptionIndex, gMenuItem.OptionBroadcastTextId); + gMenuItem.OptionBroadcastTextId = 0; + } + } + if (gMenuItem.OptionType >= GOSSIP_OPTION_MAX) - TC_LOG_ERROR("sql.sql", "Table gossip_menu_option for menu %u, id %u has unknown option id %u. Option will not be used", gMenuItem.MenuId, gMenuItem.OptionIndex, gMenuItem.OptionType); + TC_LOG_ERROR("sql.sql", "Table `gossip_menu_option` for menu %u, id %u has unknown option id %u. Option will not be used", gMenuItem.MenuId, gMenuItem.OptionIndex, gMenuItem.OptionType); if (gMenuItem.ActionPoiId && !GetPointOfInterest(gMenuItem.ActionPoiId)) { - TC_LOG_ERROR("sql.sql", "Table gossip_menu_option for menu %u, id %u use non-existing action_poi_id %u, ignoring", gMenuItem.MenuId, gMenuItem.OptionIndex, gMenuItem.ActionPoiId); + TC_LOG_ERROR("sql.sql", "Table `gossip_menu_option` for menu %u, id %u use non-existing action_poi_id %u, ignoring", gMenuItem.MenuId, gMenuItem.OptionIndex, gMenuItem.ActionPoiId); gMenuItem.ActionPoiId = 0; } + if (gMenuItem.BoxBroadcastTextId) + { + if (!GetBroadcastText(gMenuItem.BoxBroadcastTextId)) + { + TC_LOG_ERROR("sql.sql", "Table `gossip_menu_option` for menu %u, id %u has non-existing or incompatible BoxBroadcastTextId %u, ignoring.", gMenuItem.MenuId, gMenuItem.OptionIndex, gMenuItem.BoxBroadcastTextId); + gMenuItem.BoxBroadcastTextId = 0; + } + } + _gossipMenuItemsStore.insert(GossipMenuItemsContainer::value_type(gMenuItem.MenuId, gMenuItem)); ++count; } @@ -8528,6 +8572,140 @@ void ObjectMgr::CheckScripts(ScriptsType type, std::set<int32>& ids) } } +void ObjectMgr::LoadBroadcastTexts() +{ + uint32 oldMSTime = getMSTime(); + + _broadcastTextStore.clear(); // for reload case + + // 0 1 2 3 4 5 6 7 8 9 10 11 12 + QueryResult result = WorldDatabase.Query("SELECT ID, Language, MaleText, FemaleText, EmoteID0, EmoteID1, EmoteID2, EmoteDelay0, EmoteDelay1, EmoteDelay2, SoundId, Unk1, Unk2 FROM broadcast_text"); + if (!result) + { + TC_LOG_INFO("server.loading", ">> Loaded 0 broadcast texts. DB table `broadcast_text` is empty."); + return; + } + + uint32 count = 0; + + do + { + Field* fields = result->Fetch(); + + BroadcastText bct; + + bct.Id = fields[0].GetUInt32(); + bct.Language = fields[1].GetUInt32(); + AddLocaleString(fields[2].GetString(), DEFAULT_LOCALE, bct.MaleText); + AddLocaleString(fields[3].GetString(), DEFAULT_LOCALE, bct.FemaleText); + bct.EmoteId0 = fields[4].GetUInt32(); + bct.EmoteId1 = fields[5].GetUInt32(); + bct.EmoteId2 = fields[6].GetUInt32(); + bct.EmoteDelay0 = fields[7].GetUInt32(); + bct.EmoteDelay1 = fields[8].GetUInt32(); + bct.EmoteDelay2 = fields[9].GetUInt32(); + bct.SoundId = fields[10].GetUInt32(); + bct.Unk1 = fields[11].GetUInt32(); + bct.Unk2 = fields[12].GetUInt32(); + + if (bct.SoundId) + { + if (!sSoundEntriesStore.LookupEntry(bct.SoundId)) + { + TC_LOG_INFO("sql.sql", "BroadcastText (Id: %u) in table `broadcast_text` has SoundId %u but sound does not exist. Skipped.", bct.Id, bct.SoundId); + // don't load bct of higher expansions + continue; + } + } + + if (!GetLanguageDescByID(bct.Language)) + { + TC_LOG_INFO("sql.sql", "BroadcastText (Id: %u) in table `broadcast_text` using Language %u but Language does not exist. Skipped.", bct.Id, bct.Language); + // don't load bct of higher expansions + continue; + } + + if (bct.EmoteId0) + { + if (!sEmotesStore.LookupEntry(bct.EmoteId0)) + { + TC_LOG_INFO("sql.sql", "BroadcastText (Id: %u) in table `broadcast_text` has EmoteId0 %u but emote does not exist. Skipped.", bct.Id, bct.EmoteId0); + // don't load bct of higher expansions + continue; + } + } + + if (bct.EmoteId1) + { + if (!sEmotesStore.LookupEntry(bct.EmoteId1)) + { + TC_LOG_INFO("sql.sql", "BroadcastText (Id: %u) in table `broadcast_text` has EmoteId1 %u but emote does not exist. Skipped.", bct.Id, bct.EmoteId1); + // don't load bct of higher expansions + continue; + } + } + + if (bct.EmoteId2) + { + if (!sEmotesStore.LookupEntry(bct.EmoteId2)) + { + TC_LOG_INFO("sql.sql", "BroadcastText (Id: %u) in table `broadcast_text` has EmoteId2 %u but emote does not exist. Skipped.", bct.Id, bct.EmoteId2); + // don't load bct of higher expansions + continue; + } + } + + _broadcastTextStore[bct.Id] = bct; + + ++count; + } + while (result->NextRow()); + + TC_LOG_INFO("server.loading", ">> Loaded %u broadcast texts in %u ms", count, GetMSTimeDiffToNow(oldMSTime)); +} + +void ObjectMgr::LoadBroadcastTextLocales() +{ + uint32 oldMSTime = getMSTime(); + + // 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 + QueryResult result = WorldDatabase.Query("SELECT Id, MaleText_loc1, MaleText_loc2, MaleText_loc3, MaleText_loc4, MaleText_loc5, MaleText_loc6, MaleText_loc7, MaleText_loc8, FemaleText_loc1, FemaleText_loc2, FemaleText_loc3, FemaleText_loc4, FemaleText_loc5, FemaleText_loc6, FemaleText_loc7, FemaleText_loc8 FROM locales_broadcast_text"); + + if (!result) + { + TC_LOG_INFO("server.loading", ">> Loaded 0 broadcast text locales. DB table `locales_broadcast_text` is empty."); + return; + } + + uint32 count = 0; + + do + { + Field* fields = result->Fetch(); + + uint32 id = fields[0].GetUInt32(); + BroadcastTextContainer::iterator bct = _broadcastTextStore.find(id); + if (bct == _broadcastTextStore.end()) + { + TC_LOG_INFO("sql.sql", "BroadcastText (Id: %u) in table `locales_broadcast_text` does not exist or is incompatible. Skipped!", id); + // don't load bct of higher expansions + continue; + } + + for (uint8 i = 1; i < TOTAL_LOCALES; ++i) + { + LocaleConstant locale = LocaleConstant(i); + ObjectMgr::AddLocaleString(fields[1 + (i - 1)].GetString(), locale, bct->second.MaleText); + ObjectMgr::AddLocaleString(fields[9 + (i - 1)].GetString(), locale, bct->second.FemaleText); + } + + ++count; + } + while (result->NextRow()); + + TC_LOG_INFO("server.loading", ">> Loaded %u broadcast text locales in %u ms", count, GetMSTimeDiffToNow(oldMSTime)); +} + void ObjectMgr::LoadDbScriptStrings() { LoadTrinityStrings("db_script_string", MIN_DB_SCRIPT_STRING_ID, MAX_DB_SCRIPT_STRING_ID); |