diff options
author | Vincent-Michael <Vincent_Michael@gmx.de> | 2014-04-22 20:06:40 +0200 |
---|---|---|
committer | Vincent-Michael <Vincent_Michael@gmx.de> | 2014-04-22 20:06:40 +0200 |
commit | 5bb19ce01787135bc9d1a2595ef20279e3da10e6 (patch) | |
tree | 5e3319245e7ca3ba040b5065687f9fffaa9426ff /src/server/game/Texts/CreatureTextMgr.cpp | |
parent | cec7c9f07e2c9ddf5382941c227c17fd08d5b903 (diff) | |
parent | 583039c1c51ebd93975e47a1022343c626704832 (diff) |
Merge branch 'master' of github.com:TrinityCore/TrinityCore into 4.3.4
Conflicts:
src/server/game/Globals/ObjectMgr.cpp
Diffstat (limited to 'src/server/game/Texts/CreatureTextMgr.cpp')
-rw-r--r-- | src/server/game/Texts/CreatureTextMgr.cpp | 77 |
1 files changed, 45 insertions, 32 deletions
diff --git a/src/server/game/Texts/CreatureTextMgr.cpp b/src/server/game/Texts/CreatureTextMgr.cpp index 7d7e9eb7c21..f048c0fe527 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() @@ -316,14 +331,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; @@ -379,6 +392,7 @@ void CreatureTextMgr::SendNonChatPacket(WorldObject* source, WorldPacket* data, break; } + float dist = GetRangeForChatType(msgType); source->SendMessageToSetInRange(data, dist, true); } @@ -458,18 +472,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; } |