diff options
author | Aokromes <aokromes@gmail.com> | 2017-11-04 04:19:21 +0100 |
---|---|---|
committer | Aokromes <aokromes@gmail.com> | 2017-11-04 04:19:21 +0100 |
commit | fadc482c37e40da034cca36683402246d1901094 (patch) | |
tree | 5186da2b69ffa2f6272a51f5c8099c951dd86f2f /src/server/game/Texts/CreatureTextMgr.cpp | |
parent | e64f7a5ed8716b8aecde5cc4c0cd86f0a4d81f36 (diff) |
Core/Misc: Update locales_creature_text to simple system
Diffstat (limited to 'src/server/game/Texts/CreatureTextMgr.cpp')
-rw-r--r-- | src/server/game/Texts/CreatureTextMgr.cpp | 47 |
1 files changed, 25 insertions, 22 deletions
diff --git a/src/server/game/Texts/CreatureTextMgr.cpp b/src/server/game/Texts/CreatureTextMgr.cpp index 32e0bea3cc3..f3d5617c35d 100644 --- a/src/server/game/Texts/CreatureTextMgr.cpp +++ b/src/server/game/Texts/CreatureTextMgr.cpp @@ -108,8 +108,8 @@ void CreatureTextMgr::LoadCreatureTexts() Field* fields = result->Fetch(); CreatureTextEntry temp; - temp.entry = fields[0].GetUInt32(); - temp.group = fields[1].GetUInt8(); + temp.creatureId = fields[0].GetUInt32(); + temp.groupId = fields[1].GetUInt8(); temp.id = fields[2].GetUInt8(); temp.text = fields[3].GetString(); temp.type = ChatMsg(fields[4].GetUInt8()); @@ -125,20 +125,20 @@ void CreatureTextMgr::LoadCreatureTexts() { if (!sSoundKitStore.LookupEntry(temp.sound)) { - TC_LOG_ERROR("sql.sql", "CreatureTextMgr: Entry %u, Group %u in table `creature_text` has Sound %u but sound does not exist.", temp.entry, temp.group, temp.sound); + TC_LOG_ERROR("sql.sql", "CreatureTextMgr: Entry %u, Group %u in table `creature_text` has Sound %u but sound does not exist.", temp.creatureId, temp.groupId, temp.sound); temp.sound = 0; } } if (!GetLanguageDescByID(temp.lang)) { - TC_LOG_ERROR("sql.sql", "CreatureTextMgr: Entry %u, Group %u in table `creature_text` using Language %u but Language does not exist.", temp.entry, temp.group, uint32(temp.lang)); + TC_LOG_ERROR("sql.sql", "CreatureTextMgr: Entry %u, Group %u in table `creature_text` using Language %u but Language does not exist.", temp.creatureId, temp.groupId, 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_text` has Type %u but this Chat Type does not exist.", temp.entry, temp.group, uint32(temp.type)); + TC_LOG_ERROR("sql.sql", "CreatureTextMgr: Entry %u, Group %u in table `creature_text` has Type %u but this Chat Type does not exist.", temp.creatureId, temp.groupId, uint32(temp.type)); temp.type = CHAT_MSG_SAY; } @@ -146,7 +146,7 @@ void CreatureTextMgr::LoadCreatureTexts() { if (!sEmotesStore.LookupEntry(temp.emote)) { - TC_LOG_ERROR("sql.sql", "CreatureTextMgr: Entry %u, Group %u in table `creature_text` has Emote %u but emote does not exist.", temp.entry, temp.group, uint32(temp.emote)); + TC_LOG_ERROR("sql.sql", "CreatureTextMgr: Entry %u, Group %u in table `creature_text` has Emote %u but emote does not exist.", temp.creatureId, temp.groupId, uint32(temp.emote)); temp.emote = EMOTE_ONESHOT_NONE; } } @@ -155,19 +155,19 @@ void CreatureTextMgr::LoadCreatureTexts() { if (!sBroadcastTextStore.LookupEntry(temp.BroadcastTextId)) { - TC_LOG_ERROR("sql.sql", "CreatureTextMgr: Entry %u, Group %u, Id %u in table `creature_text` has non-existing or incompatible BroadcastTextId %u.", temp.entry, temp.group, temp.id, temp.BroadcastTextId); + TC_LOG_ERROR("sql.sql", "CreatureTextMgr: Entry %u, Group %u, Id %u in table `creature_text` has non-existing or incompatible BroadcastTextId %u.", temp.creatureId, temp.groupId, temp.id, temp.BroadcastTextId); temp.BroadcastTextId = 0; } } if (temp.TextRange > TEXT_RANGE_WORLD) { - TC_LOG_ERROR("sql.sql", "CreatureTextMgr: Entry %u, Group %u, Id %u in table `creature_text` has incorrect TextRange %u.", temp.entry, temp.group, temp.id, temp.TextRange); + TC_LOG_ERROR("sql.sql", "CreatureTextMgr: Entry %u, Group %u, Id %u in table `creature_text` has incorrect TextRange %u.", temp.creatureId, temp.groupId, temp.id, temp.TextRange); temp.TextRange = TEXT_RANGE_NORMAL; } // add the text into our entry's group - mTextMap[temp.entry][temp.group].push_back(temp); + mTextMap[temp.creatureId][temp.groupId].push_back(temp); ++textCount; } @@ -182,27 +182,30 @@ void CreatureTextMgr::LoadCreatureTextLocales() mLocaleTextMap.clear(); // for reload case - QueryResult result = WorldDatabase.Query("SELECT entry, groupid, id, text_loc1, text_loc2, text_loc3, text_loc4, text_loc5, text_loc6, text_loc7, text_loc8 FROM locales_creature_text"); + QueryResult result = WorldDatabase.Query("SELECT CreatureId, GroupId, ID, Locale, Text FROM creature_text_locale"); if (!result) return; - uint32 textCount = 0; - do { Field* fields = result->Fetch(); - CreatureTextLocale& loc = mLocaleTextMap[CreatureTextId(fields[0].GetUInt32(), uint32(fields[1].GetUInt8()), uint32(fields[2].GetUInt8()))]; - for (uint8 i = OLD_TOTAL_LOCALES - 1; i > 0; --i) - { - LocaleConstant locale = LocaleConstant(i); - ObjectMgr::AddLocaleString(fields[3 + i - 1].GetString(), locale, loc.Text); - } - ++textCount; + uint32 creatureId = fields[0].GetUInt32(); + uint32 groupId = fields[1].GetUInt8(); + uint32 id = fields[2].GetUInt8(); + std::string localeName = fields[3].GetString(); + std::string text = fields[4].GetString(); + + CreatureTextLocale& data = mLocaleTextMap[CreatureTextId(creatureId, groupId, id)]; + LocaleConstant locale = GetLocaleByName(localeName); + if (locale == LOCALE_enUS) + continue; + + ObjectMgr::AddLocaleString(text, locale, data.Text); } while (result->NextRow()); - TC_LOG_INFO("server.loading", ">> Loaded %u creature localized texts in %u ms", textCount, GetMSTimeDiffToNow(oldMSTime)); + TC_LOG_INFO("server.loading", ">> Loaded %u creature localized texts in %u ms", uint32(mLocaleTextMap.size()), GetMSTimeDiffToNow(oldMSTime)); } uint32 CreatureTextMgr::SendChat(Creature* source, uint8 textGroup, WorldObject const* whisperTarget /*= nullptr*/, ChatMsg msgType /*= CHAT_MSG_ADDON*/, Language language /*= LANG_ADDON*/, CreatureTextRange range /*= TEXT_RANGE_NORMAL*/, uint32 sound /*= 0*/, Team team /*= TEAM_OTHER*/, bool gmOnly /*= false*/, Player* srcPlr /*= nullptr*/) @@ -268,12 +271,12 @@ uint32 CreatureTextMgr::SendChat(Creature* source, uint8 textGroup, WorldObject if (srcPlr) { - PlayerTextBuilder builder(source, finalSource, finalSource->getGender(), finalType, iter->group, iter->id, finalLang, whisperTarget); + PlayerTextBuilder builder(source, finalSource, finalSource->getGender(), finalType, iter->groupId, iter->id, finalLang, whisperTarget); SendChatPacket(finalSource, builder, finalType, whisperTarget, range, team, gmOnly); } else { - CreatureTextBuilder builder(finalSource, finalSource->getGender(), finalType, iter->group, iter->id, finalLang, whisperTarget); + CreatureTextBuilder builder(finalSource, finalSource->getGender(), finalType, iter->groupId, iter->id, finalLang, whisperTarget); SendChatPacket(finalSource, builder, finalType, whisperTarget, range, team, gmOnly); } |