diff options
Diffstat (limited to 'src/server/game/Texts/CreatureTextMgr.cpp')
-rwxr-xr-x | src/server/game/Texts/CreatureTextMgr.cpp | 59 |
1 files changed, 54 insertions, 5 deletions
diff --git a/src/server/game/Texts/CreatureTextMgr.cpp b/src/server/game/Texts/CreatureTextMgr.cpp index 5c2639175d2..89b75fd1695 100755 --- a/src/server/game/Texts/CreatureTextMgr.cpp +++ b/src/server/game/Texts/CreatureTextMgr.cpp @@ -65,6 +65,47 @@ class CreatureTextBuilder uint64 _targetGUID; }; +class PlayerTextBuilder +{ + public: + PlayerTextBuilder(WorldObject* obj, WorldObject* speaker, ChatMsg msgtype, uint8 textGroup, uint32 id, uint32 language, uint64 targetGUID) + : _source(obj), _talker(speaker), _msgType(msgtype), _textGroup(textGroup), _textId(id), _language(language), _targetGUID(targetGUID) + { + } + + size_t operator()(WorldPacket* data, LocaleConstant locale) const + { + std::string const& text = sCreatureTextMgr->GetLocalizedChatString(_source->GetEntry(), _textGroup, _textId, locale); + + *data << uint8(_msgType); + *data << uint32(_language); + *data << uint64(_talker->GetGUID()); + *data << uint32(1); // 2.1.0 + *data << uint32(_talker->GetName().size() + 1); + *data << _talker->GetName(); + size_t whisperGUIDpos = data->wpos(); + *data << uint64(_targetGUID); // Unit Target + if (_targetGUID && !IS_PLAYER_GUID(_targetGUID)) + { + *data << uint32(1); // target name length + *data << uint8(0); // target name + } + *data << uint32(text.length() + 1); + *data << text; + *data << uint8(0); // ChatTag + + return whisperGUIDpos; + } + + WorldObject* _source; + WorldObject* _talker; + ChatMsg _msgType; + uint8 _textGroup; + uint32 _textId; + uint32 _language; + uint64 _targetGUID; +}; + void CreatureTextMgr::LoadCreatureTexts() { uint32 oldMSTime = getMSTime(); @@ -170,7 +211,7 @@ void CreatureTextMgr::LoadCreatureTextLocales() } -uint32 CreatureTextMgr::SendChat(Creature* source, uint8 textGroup, uint64 whisperGuid /*= 0*/, ChatMsg msgType /*= CHAT_MSG_ADDON*/, Language language /*= LANG_ADDON*/, TextRange range /*= TEXT_RANGE_NORMAL*/, uint32 sound /*= 0*/, Team team /*= TEAM_OTHER*/, bool gmOnly /*= false*/, Player* srcPlr /*= NULL*/) +uint32 CreatureTextMgr::SendChat(Creature* source, uint8 textGroup, uint64 whisperGuid /*= 0*/, 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 /*= NULL*/) { if (!source) return 0; @@ -261,8 +302,16 @@ uint32 CreatureTextMgr::SendChat(Creature* source, uint8 textGroup, uint64 whisp if (iter->emote) SendEmote(finalSource, iter->emote); - CreatureTextBuilder builder(finalSource, finalType, iter->group, iter->id, finalLang, whisperGuid); - SendChatPacket(finalSource, builder, finalType, whisperGuid, range, team, gmOnly); + if (srcPlr) + { + PlayerTextBuilder builder(source, finalSource, finalType, iter->group, iter->id, finalLang, whisperGuid); + SendChatPacket(finalSource, builder, finalType, whisperGuid, range, team, gmOnly); + } + else + { + CreatureTextBuilder builder(finalSource, finalType, iter->group, iter->id, finalLang, whisperGuid); + SendChatPacket(finalSource, builder, finalType, whisperGuid, range, team, gmOnly); + } if (isEqualChanced || (!isEqualChanced && totalChance == 100.0f)) SetRepeatId(source, textGroup, iter->id); @@ -288,7 +337,7 @@ float CreatureTextMgr::GetRangeForChatType(ChatMsg msgType) const return dist; } -void CreatureTextMgr::SendSound(Creature* source, uint32 sound, ChatMsg msgType, uint64 whisperGuid, TextRange range, Team team, bool gmOnly) +void CreatureTextMgr::SendSound(Creature* source, uint32 sound, ChatMsg msgType, uint64 whisperGuid, CreatureTextRange range, Team team, bool gmOnly) { if (!sound || !source) return; @@ -298,7 +347,7 @@ void CreatureTextMgr::SendSound(Creature* source, uint32 sound, ChatMsg msgType, SendNonChatPacket(source, &data, msgType, whisperGuid, range, team, gmOnly); } -void CreatureTextMgr::SendNonChatPacket(WorldObject* source, WorldPacket* data, ChatMsg msgType, uint64 whisperGuid, TextRange range, Team team, bool gmOnly) const +void CreatureTextMgr::SendNonChatPacket(WorldObject* source, WorldPacket* data, ChatMsg msgType, uint64 whisperGuid, CreatureTextRange range, Team team, bool gmOnly) const { float dist = GetRangeForChatType(msgType); |