diff options
author | joschiwald <joschiwald.trinity@gmail.com> | 2014-04-22 17:57:23 +0200 |
---|---|---|
committer | joschiwald <joschiwald.trinity@gmail.com> | 2014-04-22 17:57:23 +0200 |
commit | 742f32f15a9321d755c5cfe1c266925f6b4c02a2 (patch) | |
tree | 654545bcc4abb3cdb1b12830f81232373241d9a9 /src | |
parent | 805a026c6c8c40f1092eda64dc187b840c68d2bb (diff) |
Core/Texts: Implemented loading BroadcastTexts
Diffstat (limited to 'src')
-rw-r--r-- | src/server/game/Globals/ObjectMgr.cpp | 236 | ||||
-rw-r--r-- | src/server/game/Globals/ObjectMgr.h | 33 | ||||
-rw-r--r-- | src/server/game/Texts/CreatureTextMgr.cpp | 77 | ||||
-rw-r--r-- | src/server/game/Texts/CreatureTextMgr.h | 3 | ||||
-rw-r--r-- | src/server/game/World/World.cpp | 4 | ||||
-rw-r--r-- | src/server/shared/Database/Implementation/WorldDatabase.cpp | 2 |
6 files changed, 292 insertions, 63 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); diff --git a/src/server/game/Globals/ObjectMgr.h b/src/server/game/Globals/ObjectMgr.h index b1f80af0567..825ff3a740f 100644 --- a/src/server/game/Globals/ObjectMgr.h +++ b/src/server/game/Globals/ObjectMgr.h @@ -410,6 +410,26 @@ struct AreaTrigger float target_Orientation; }; +struct BroadcastText +{ + uint32 Id; + uint32 Language; + StringVector MaleText; + StringVector FemaleText; + uint32 EmoteId0; + uint32 EmoteId1; + uint32 EmoteId2; + uint32 EmoteDelay0; + uint32 EmoteDelay1; + uint32 EmoteDelay2; + uint32 SoundId; + uint32 Unk1; + uint32 Unk2; + // uint32 WDBVerified; +}; + +typedef UNORDERED_MAP<uint32, BroadcastText> BroadcastTextContainer; + typedef std::set<uint32> CellGuidSet; typedef std::map<uint32/*player guid*/, uint32/*instance*/> CellCorpseSet; struct CellObjectGuids @@ -527,6 +547,7 @@ struct GossipMenuItems uint32 OptionIndex; uint8 OptionIcon; std::string OptionText; + uint32 OptionBroadcastTextId; uint32 OptionType; uint32 OptionNpcflag; uint32 ActionMenuId; @@ -534,6 +555,7 @@ struct GossipMenuItems bool BoxCoded; uint32 BoxMoney; std::string BoxText; + uint32 BoxBroadcastTextId; ConditionList Conditions; }; @@ -905,6 +927,8 @@ class ObjectMgr void LoadSpellScriptNames(); void ValidateSpellScripts(); + void LoadBroadcastTexts(); + void LoadBroadcastTextLocales(); bool LoadTrinityStrings(char const* table, int32 min_value, int32 max_value); bool LoadTrinityStrings() { return LoadTrinityStrings("trinity_string", MIN_TRINITY_STRING_ID, MAX_TRINITY_STRING_ID); } void LoadDbScriptStrings(); @@ -1042,6 +1066,14 @@ class ObjectMgr return NULL; } + BroadcastText const* GetBroadcastText(uint32 id) const + { + BroadcastTextContainer::const_iterator itr = _broadcastTextStore.find(id); + if (itr != _broadcastTextStore.end()) + return &itr->second; + return NULL; + } + CreatureData const* GetCreatureData(uint32 guid) const { CreatureDataContainer::const_iterator itr = _creatureDataStore.find(guid); @@ -1361,6 +1393,7 @@ class ObjectMgr /// Stores temp summon data grouped by summoner's entry, summoner's type and group id TempSummonDataContainer _tempSummonDataStore; + BroadcastTextContainer _broadcastTextStore; ItemTemplateContainer _itemTemplateStore; ItemLocaleContainer _itemLocaleStore; ItemSetNameLocaleContainer _itemSetNameLocaleStore; diff --git a/src/server/game/Texts/CreatureTextMgr.cpp b/src/server/game/Texts/CreatureTextMgr.cpp index b89c64165c3..b7cc47642c0 100644 --- a/src/server/game/Texts/CreatureTextMgr.cpp +++ b/src/server/game/Texts/CreatureTextMgr.cpp @@ -28,7 +28,7 @@ class CreatureTextBuilder { public: - CreatureTextBuilder(WorldObject* obj, ChatMsg msgtype, uint8 textGroup, uint32 id, uint32 language, WorldObject const* target) + CreatureTextBuilder(WorldObject const* obj, ChatMsg msgtype, uint8 textGroup, uint32 id, uint32 language, WorldObject const* target) : _source(obj), _msgType(msgtype), _textGroup(textGroup), _textId(id), _language(language), _target(target) { } @@ -40,7 +40,7 @@ class CreatureTextBuilder return ChatHandler::BuildChatPacket(*data, _msgType, Language(_language), _source, _target, text, 0, "", locale); } - WorldObject* _source; + WorldObject const* _source; ChatMsg _msgType; uint8 _textGroup; uint32 _textId; @@ -51,7 +51,7 @@ class CreatureTextBuilder class PlayerTextBuilder { public: - PlayerTextBuilder(WorldObject* obj, WorldObject* speaker, ChatMsg msgtype, uint8 textGroup, uint32 id, uint32 language, WorldObject const* target) + PlayerTextBuilder(WorldObject const* obj, WorldObject const* speaker, ChatMsg msgtype, uint8 textGroup, uint32 id, uint32 language, WorldObject const* target) : _source(obj), _talker(speaker), _msgType(msgtype), _textGroup(textGroup), _textId(id), _language(language), _target(target) { } @@ -63,8 +63,8 @@ class PlayerTextBuilder return ChatHandler::BuildChatPacket(*data, _msgType, Language(_language), _talker, _target, text, 0, "", locale); } - WorldObject* _source; - WorldObject* _talker; + WorldObject const* _source; + WorldObject const* _talker; ChatMsg _msgType; uint8 _textGroup; uint32 _textId; @@ -97,34 +97,39 @@ void CreatureTextMgr::LoadCreatureTexts() Field* fields = result->Fetch(); CreatureTextEntry temp; - temp.entry = fields[0].GetUInt32(); - temp.group = fields[1].GetUInt8(); - temp.id = fields[2].GetUInt8(); - temp.text = fields[3].GetString(); - temp.type = ChatMsg(fields[4].GetUInt8()); - temp.lang = Language(fields[5].GetUInt8()); - temp.probability = fields[6].GetFloat(); - temp.emote = Emote(fields[7].GetUInt32()); - temp.duration = fields[8].GetUInt32(); - temp.sound = fields[9].GetUInt32(); + temp.entry = fields[0].GetUInt32(); + temp.group = fields[1].GetUInt8(); + temp.id = fields[2].GetUInt8(); + temp.text = fields[3].GetString(); + temp.type = ChatMsg(fields[4].GetUInt8()); + temp.lang = Language(fields[5].GetUInt8()); + temp.probability = fields[6].GetFloat(); + temp.emote = Emote(fields[7].GetUInt32()); + temp.duration = fields[8].GetUInt32(); + temp.sound = fields[9].GetUInt32(); + temp.BroadcastTextId = fields[10].GetUInt32(); if (temp.sound) { - if (!sSoundEntriesStore.LookupEntry(temp.sound)){ + if (!sSoundEntriesStore.LookupEntry(temp.sound)) + { TC_LOG_ERROR("sql.sql", "CreatureTextMgr: Entry %u, Group %u in table `creature_texts` has Sound %u but sound does not exist.", temp.entry, temp.group, temp.sound); temp.sound = 0; } } + if (!GetLanguageDescByID(temp.lang)) { TC_LOG_ERROR("sql.sql", "CreatureTextMgr: Entry %u, Group %u in table `creature_texts` using Language %u but Language does not exist.", temp.entry, temp.group, uint32(temp.lang)); temp.lang = LANG_UNIVERSAL; } + if (temp.type >= MAX_CHAT_MSG_TYPE) { TC_LOG_ERROR("sql.sql", "CreatureTextMgr: Entry %u, Group %u in table `creature_texts` has Type %u but this Chat Type does not exist.", temp.entry, temp.group, uint32(temp.type)); temp.type = CHAT_MSG_SAY; } + if (temp.emote) { if (!sEmotesStore.LookupEntry(temp.emote)) @@ -133,18 +138,28 @@ void CreatureTextMgr::LoadCreatureTexts() temp.emote = EMOTE_ONESHOT_NONE; } } - //entry not yet added, add empty TextHolder (list of groups) + + if (temp.BroadcastTextId) + { + if (!sObjectMgr->GetBroadcastText(temp.BroadcastTextId)) + { + TC_LOG_ERROR("sql.sql", "CreatureTextMgr: Entry %u, Group %u, Id %u in table `creature_texts` has non-existing or incompatible BroadcastTextId %u.", temp.entry, temp.group, temp.id, temp.BroadcastTextId); + temp.BroadcastTextId = 0; + } + } + + // entry not yet added, add empty TextHolder (list of groups) if (mTextMap.find(temp.entry) == mTextMap.end()) ++creatureCount; - //add the text into our entry's group + // add the text into our entry's group mTextMap[temp.entry][temp.group].push_back(temp); ++textCount; - } while (result->NextRow()); + } + while (result->NextRow()); TC_LOG_INFO("server.loading", ">> Loaded %u creature texts for %u creatures in %u ms", textCount, creatureCount, GetMSTimeDiffToNow(oldMSTime)); - } void CreatureTextMgr::LoadCreatureTextLocales() @@ -315,14 +330,12 @@ void CreatureTextMgr::SendSound(Creature* source, uint32 sound, ChatMsg msgType, void CreatureTextMgr::SendNonChatPacket(WorldObject* source, WorldPacket* data, ChatMsg msgType, WorldObject const* whisperTarget, CreatureTextRange range, Team team, bool gmOnly) const { - float dist = GetRangeForChatType(msgType); - switch (msgType) { case CHAT_MSG_MONSTER_WHISPER: case CHAT_MSG_RAID_BOSS_WHISPER: { - if (range == TEXT_RANGE_NORMAL)//ignores team and gmOnly + if (range == TEXT_RANGE_NORMAL) // ignores team and gmOnly { if (!whisperTarget || whisperTarget->GetTypeId() != TYPEID_PLAYER) return; @@ -378,6 +391,7 @@ void CreatureTextMgr::SendNonChatPacket(WorldObject* source, WorldPacket* data, break; } + float dist = GetRangeForChatType(msgType); source->SendMessageToSetInRange(data, dist, true); } @@ -457,18 +471,17 @@ std::string CreatureTextMgr::GetLocalizedChatString(uint32 entry, uint8 textGrou if (groupItr == holderItr->second.end()) return ""; - std::string baseText = groupItr->text; - if (locale == DEFAULT_LOCALE) - return baseText; - if (locale > MAX_LOCALES) - return baseText; + locale = DEFAULT_LOCALE; - LocaleCreatureTextMap::const_iterator locItr = mLocaleTextMap.find(CreatureTextId(entry, uint32(textGroup), id)); - if (locItr == mLocaleTextMap.end()) - return baseText; + std::string baseText = groupItr->text; - ObjectMgr::GetLocaleString(locItr->second.Text, locale, baseText); + if (locale != DEFAULT_LOCALE) + { + LocaleCreatureTextMap::const_iterator locItr = mLocaleTextMap.find(CreatureTextId(entry, uint32(textGroup), id)); + if (locItr != mLocaleTextMap.end()) + ObjectMgr::GetLocaleString(locItr->second.Text, locale, baseText); + } return baseText; } diff --git a/src/server/game/Texts/CreatureTextMgr.h b/src/server/game/Texts/CreatureTextMgr.h index 12236844828..c3bc8966563 100644 --- a/src/server/game/Texts/CreatureTextMgr.h +++ b/src/server/game/Texts/CreatureTextMgr.h @@ -36,6 +36,7 @@ struct CreatureTextEntry Emote emote; uint32 duration; uint32 sound; + uint32 BroadcastTextId; }; enum CreatureTextRange @@ -186,7 +187,7 @@ void CreatureTextMgr::SendChatPacket(WorldObject* source, Builder const& builder case CHAT_MSG_MONSTER_WHISPER: case CHAT_MSG_RAID_BOSS_WHISPER: { - if (range == TEXT_RANGE_NORMAL) //ignores team and gmOnly + if (range == TEXT_RANGE_NORMAL) // ignores team and gmOnly { if (!whisperTarget || whisperTarget->GetTypeId() != TYPEID_PLAYER) return; diff --git a/src/server/game/World/World.cpp b/src/server/game/World/World.cpp index 8f2941865fa..e40e2f7e6d1 100644 --- a/src/server/game/World/World.cpp +++ b/src/server/game/World/World.cpp @@ -1352,6 +1352,10 @@ void World::SetInitialWorldSettings() TC_LOG_INFO("server.loading", "Loading instances..."); sInstanceSaveMgr->LoadInstances(); + TC_LOG_INFO("server.loading", "Loading Broadcast texts..."); + sObjectMgr->LoadBroadcastTexts(); + sObjectMgr->LoadBroadcastTextLocales(); + TC_LOG_INFO("server.loading", "Loading Localization strings..."); uint32 oldMSTime = getMSTime(); sObjectMgr->LoadCreatureLocales(); diff --git a/src/server/shared/Database/Implementation/WorldDatabase.cpp b/src/server/shared/Database/Implementation/WorldDatabase.cpp index 644d3b330fb..78fd859ea8f 100644 --- a/src/server/shared/Database/Implementation/WorldDatabase.cpp +++ b/src/server/shared/Database/Implementation/WorldDatabase.cpp @@ -25,7 +25,7 @@ void WorldDatabaseConnection::DoPrepareStatements() PrepareStatement(WORLD_SEL_QUEST_POOLS, "SELECT entry, pool_entry FROM pool_quest", CONNECTION_SYNCH); PrepareStatement(WORLD_DEL_CRELINKED_RESPAWN, "DELETE FROM linked_respawn WHERE guid = ?", CONNECTION_ASYNC); PrepareStatement(WORLD_REP_CREATURE_LINKED_RESPAWN, "REPLACE INTO linked_respawn (guid, linkedGuid) VALUES (?, ?)", CONNECTION_ASYNC); - PrepareStatement(WORLD_SEL_CREATURE_TEXT, "SELECT entry, groupid, id, text, type, language, probability, emote, duration, sound FROM creature_text", CONNECTION_SYNCH); + PrepareStatement(WORLD_SEL_CREATURE_TEXT, "SELECT entry, groupid, id, text, type, language, probability, emote, duration, sound, BroadcastTextID FROM creature_text", CONNECTION_SYNCH); PrepareStatement(WORLD_SEL_SMART_SCRIPTS, "SELECT entryorguid, source_type, id, link, event_type, event_phase_mask, event_chance, event_flags, event_param1, event_param2, event_param3, event_param4, action_type, action_param1, action_param2, action_param3, action_param4, action_param5, action_param6, target_type, target_param1, target_param2, target_param3, target_x, target_y, target_z, target_o FROM smart_scripts ORDER BY entryorguid, source_type, id, link", CONNECTION_SYNCH); PrepareStatement(WORLD_SEL_SMARTAI_WP, "SELECT entry, pointid, position_x, position_y, position_z FROM waypoints ORDER BY entry, pointid", CONNECTION_SYNCH); PrepareStatement(WORLD_DEL_GAMEOBJECT, "DELETE FROM gameobject WHERE guid = ?", CONNECTION_ASYNC); |