aboutsummaryrefslogtreecommitdiff
path: root/src/server/game/Texts
diff options
context:
space:
mode:
authorjoschiwald <joschiwald.trinity@gmail.com>2014-12-23 00:06:36 +0100
committerjoschiwald <joschiwald.trinity@gmail.com>2014-12-23 00:06:36 +0100
commit6c6e4d4328526ccfcd9049efbf9033fe47de41a6 (patch)
tree32e7f776afd1b527302f3addd1dde812d84585d8 /src/server/game/Texts
parentbf8eff8545d092585a1c710dc0b251b8cd0654bb (diff)
Core/Packets: moved chat packet building function to packet builder class
Diffstat (limited to 'src/server/game/Texts')
-rw-r--r--src/server/game/Texts/ChatTextBuilder.h10
-rw-r--r--src/server/game/Texts/CreatureTextMgr.cpp20
-rw-r--r--src/server/game/Texts/CreatureTextMgr.h18
3 files changed, 26 insertions, 22 deletions
diff --git a/src/server/game/Texts/ChatTextBuilder.h b/src/server/game/Texts/ChatTextBuilder.h
index a4834d555d3..1cab1f3576c 100644
--- a/src/server/game/Texts/ChatTextBuilder.h
+++ b/src/server/game/Texts/ChatTextBuilder.h
@@ -34,8 +34,9 @@ namespace Trinity
{
BroadcastText const* bct = sObjectMgr->GetBroadcastText(_textId);
WorldPackets::Chat::Chat packet;
- ChatHandler::BuildChatPacket(&packet, _msgType, bct ? Language(bct->Language) : LANG_UNIVERSAL, _source, _target, bct ? bct->GetText(locale, _source->getGender()) : "", _achievementId, "", locale);
- data = *packet.Write();
+ packet.Initalize(_msgType, bct ? Language(bct->Language) : LANG_UNIVERSAL, _source, _target, bct ? bct->GetText(locale, _source->getGender()) : "", _achievementId, "", locale);
+ packet.Write();
+ data = packet.Move();
}
private:
@@ -55,8 +56,9 @@ namespace Trinity
void operator()(WorldPacket& data, LocaleConstant locale)
{
WorldPackets::Chat::Chat packet;
- ChatHandler::BuildChatPacket(&packet, _msgType, _language, _source, _target, _text, 0, "", locale);
- data = *packet.Write();
+ packet.Initalize(_msgType, _language, _source, _target, _text, 0, "", locale);
+ packet.Write();
+ data = packet.Move();
}
private:
diff --git a/src/server/game/Texts/CreatureTextMgr.cpp b/src/server/game/Texts/CreatureTextMgr.cpp
index 992942cefeb..7f299c57c21 100644
--- a/src/server/game/Texts/CreatureTextMgr.cpp
+++ b/src/server/game/Texts/CreatureTextMgr.cpp
@@ -36,8 +36,9 @@ class CreatureTextBuilder
{
std::string const& text = sCreatureTextMgr->GetLocalizedChatString(_source->GetEntry(), _gender, _textGroup, _textId, locale);
WorldPackets::Chat::Chat packet;
- ChatHandler::BuildChatPacket(&packet, _msgType, Language(_language), _source, _target, text, 0, "", locale);
- data = *packet.Write();
+ packet.Initalize(_msgType, Language(_language), _source, _target, text, 0, "", locale);
+ packet.Write();
+ data = packet.Move();
}
private:
@@ -60,8 +61,9 @@ class PlayerTextBuilder
{
std::string const& text = sCreatureTextMgr->GetLocalizedChatString(_source->GetEntry(), _gender, _textGroup, _textId, locale);
WorldPackets::Chat::Chat packet;
- ChatHandler::BuildChatPacket(&packet, _msgType, Language(_language), _talker, _target, text, 0, "", locale);
- data = *packet.Write();
+ packet.Initalize(_msgType, Language(_language), _talker, _target, text, 0, "", locale);
+ packet.Write();
+ data = packet.Move();
}
private:
@@ -308,7 +310,7 @@ uint32 CreatureTextMgr::SendChat(Creature* source, uint8 textGroup, WorldObject
return iter->duration;
}
-float CreatureTextMgr::GetRangeForChatType(ChatMsg msgType) const
+float CreatureTextMgr::GetRangeForChatType(ChatMsg msgType)
{
float dist = sWorld->getFloatConfig(CONFIG_LISTEN_RANGE_SAY);
switch (msgType)
@@ -327,7 +329,7 @@ float CreatureTextMgr::GetRangeForChatType(ChatMsg msgType) const
return dist;
}
-void CreatureTextMgr::SendSound(Creature* source, uint32 sound, ChatMsg msgType, WorldObject const* whisperTarget, CreatureTextRange range, Team team, bool gmOnly)
+void CreatureTextMgr::SendSound(Creature* source, uint32 sound, ChatMsg msgType, WorldObject const* whisperTarget /*= nullptr*/, CreatureTextRange range /*= TEXT_RANGE_NORMAL*/, Team team /*= TEAM_OTHER*/, bool gmOnly /*= false*/)
{
if (!sound || !source)
return;
@@ -338,7 +340,7 @@ void CreatureTextMgr::SendSound(Creature* source, uint32 sound, ChatMsg msgType,
SendNonChatPacket(source, &data, msgType, whisperTarget, range, team, gmOnly);
}
-void CreatureTextMgr::SendNonChatPacket(WorldObject* source, WorldPacket* data, ChatMsg msgType, WorldObject const* whisperTarget, CreatureTextRange range, Team team, bool gmOnly) const
+void CreatureTextMgr::SendNonChatPacket(WorldObject* source, WorldPacket* data, ChatMsg msgType, WorldObject const* whisperTarget, CreatureTextRange range, Team team, bool gmOnly)
{
switch (msgType)
{
@@ -437,7 +439,7 @@ void CreatureTextMgr::SetRepeatId(Creature* source, uint8 textGroup, uint8 id)
TC_LOG_ERROR("sql.sql", "CreatureTextMgr: TextGroup %u for Creature (%s) %s, id %u already added", uint32(textGroup), source->GetName().c_str(), source->GetGUID().ToString().c_str(), uint32(id));
}
-CreatureTextRepeatIds CreatureTextMgr::GetRepeatGroup(Creature* source, uint8 textGroup)
+CreatureTextRepeatIds CreatureTextMgr::GetRepeatGroup(Creature* source, uint8 textGroup) const
{
ASSERT(source);//should never happen
CreatureTextRepeatIds ids;
@@ -452,7 +454,7 @@ CreatureTextRepeatIds CreatureTextMgr::GetRepeatGroup(Creature* source, uint8 te
return ids;
}
-bool CreatureTextMgr::TextExist(uint32 sourceEntry, uint8 textGroup)
+bool CreatureTextMgr::TextExist(uint32 sourceEntry, uint8 textGroup) const
{
if (!sourceEntry)
return false;
diff --git a/src/server/game/Texts/CreatureTextMgr.h b/src/server/game/Texts/CreatureTextMgr.h
index 647d8249e68..f15ec94c69b 100644
--- a/src/server/game/Texts/CreatureTextMgr.h
+++ b/src/server/game/Texts/CreatureTextMgr.h
@@ -96,24 +96,24 @@ class CreatureTextMgr
void LoadCreatureTexts();
void LoadCreatureTextLocales();
- CreatureTextMap const& GetTextMap() const { return mTextMap; }
+ CreatureTextMap const& GetTextMap() const { return mTextMap; }
- void SendSound(Creature* source, uint32 sound, ChatMsg msgType, WorldObject const* whisperTarget, CreatureTextRange range, Team team, bool gmOnly);
- void SendEmote(Unit* source, uint32 emote);
+ static void SendSound(Creature* source, uint32 sound, ChatMsg msgType, WorldObject const* whisperTarget = nullptr, CreatureTextRange range = TEXT_RANGE_NORMAL, Team team = TEAM_OTHER, bool gmOnly = false);
+ static void SendEmote(Unit* source, uint32 emote);
//if sent, returns the 'duration' of the text else 0 if error
uint32 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);
- bool TextExist(uint32 sourceEntry, uint8 textGroup);
+ bool TextExist(uint32 sourceEntry, uint8 textGroup) const;
std::string GetLocalizedChatString(uint32 entry, uint8 gender, uint8 textGroup, uint32 id, LocaleConstant locale) const;
- template<class Builder> void SendChatPacket(WorldObject* source, Builder const& builder, ChatMsg msgType, WorldObject const* whisperTarget = nullptr, CreatureTextRange range = TEXT_RANGE_NORMAL, Team team = TEAM_OTHER, bool gmOnly = false) const;
+ template<class Builder> static void SendChatPacket(WorldObject* source, Builder const& builder, ChatMsg msgType, WorldObject const* whisperTarget = nullptr, CreatureTextRange range = TEXT_RANGE_NORMAL, Team team = TEAM_OTHER, bool gmOnly = false);
private:
- CreatureTextRepeatIds GetRepeatGroup(Creature* source, uint8 textGroup);
+ CreatureTextRepeatIds GetRepeatGroup(Creature* source, uint8 textGroup) const;
void SetRepeatId(Creature* source, uint8 textGroup, uint8 id);
- void SendNonChatPacket(WorldObject* source, WorldPacket* data, ChatMsg msgType, WorldObject const* whisperTarget, CreatureTextRange range, Team team, bool gmOnly) const;
- float GetRangeForChatType(ChatMsg msgType) const;
+ static void SendNonChatPacket(WorldObject* source, WorldPacket* data, ChatMsg msgType, WorldObject const* whisperTarget, CreatureTextRange range, Team team, bool gmOnly);
+ static float GetRangeForChatType(ChatMsg msgType);
CreatureTextMap mTextMap;
CreatureTextRepeatMap mTextRepeatMap;
@@ -171,7 +171,7 @@ class CreatureTextLocalizer
};
template<class Builder>
-void CreatureTextMgr::SendChatPacket(WorldObject* source, Builder const& builder, ChatMsg msgType, WorldObject const* whisperTarget /*= nullptr*/, CreatureTextRange range /*= TEXT_RANGE_NORMAL*/, Team team /*= TEAM_OTHER*/, bool gmOnly /*= false*/) const
+void CreatureTextMgr::SendChatPacket(WorldObject* source, Builder const& builder, ChatMsg msgType, WorldObject const* whisperTarget /*= nullptr*/, CreatureTextRange range /*= TEXT_RANGE_NORMAL*/, Team team /*= TEAM_OTHER*/, bool gmOnly /*= false*/)
{
if (!source)
return;