Core/Packets: moved chat packet building function to packet builder class

This commit is contained in:
joschiwald
2014-12-23 00:06:36 +01:00
parent bf8eff8545
commit 6c6e4d4328
27 changed files with 249 additions and 232 deletions

View File

@@ -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;