TrinityCore
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
WorldPackets::Chat::Chat Class Referencefinal

#include <ChatPackets.h>

Public Member Functions

 Chat ()
 
 Chat (Chat const &chat)
 
void Initialize (ChatMsg chatType, Language language, WorldObject const *sender, WorldObject const *receiver, std::string message, uint32 achievementId=0, std::string channelName="", LocaleConstant locale=DEFAULT_LOCALE, std::string addonPrefix="")
 
void SetSender (WorldObject const *sender, LocaleConstant locale)
 
void SetReceiver (WorldObject const *receiver, LocaleConstant locale)
 
WorldPacket constWrite () override
 
- Public Member Functions inherited from WorldPackets::ServerPacket
 ServerPacket (OpcodeServer opcode, size_t initialSize=200, ConnectionType connection=CONNECTION_TYPE_DEFAULT)
 
void Read () overridefinal
 
void Clear ()
 
WorldPacket && Move ()
 
OpcodeServer GetOpcode () const
 
- Public Member Functions inherited from WorldPackets::Packet
 Packet (WorldPacket &&worldPacket)
 
virtual ~Packet ()=default
 
 Packet (Packet const &right)=delete
 
Packetoperator= (Packet const &right)=delete
 
WorldPacket constGetRawPacket () const
 
size_t GetSize () const
 
ConnectionType GetConnection () const
 

Public Attributes

uint8 SlashCmd = 0
 
uint8 _Language = LANG_UNIVERSAL
 
ObjectGuid SenderGUID
 
ObjectGuid SenderGuildGUID
 
ObjectGuid SenderAccountGUID
 
ObjectGuid TargetGUID
 
ObjectGuid PartyGUID
 
uint32 SenderVirtualAddress = 0
 
uint32 TargetVirtualAddress = 0
 
std::string SenderName
 
std::string TargetName
 
std::string Prefix
 Addon Prefix. More...
 
std::string _Channel
 Channel Name. More...
 
std::string ChatText
 
uint32 AchievementID = 0
 
uint8 _ChatFlags = 0
 
float DisplayTime = 0.0f
 
bool HideChatLog = false
 
bool FakeSenderName = false
 

Additional Inherited Members

- Protected Attributes inherited from WorldPackets::Packet
WorldPacket _worldPacket
 

Constructor & Destructor Documentation

WorldPackets::Chat::Chat::Chat ( )
inline
153 : ServerPacket(SMSG_CHAT, 100) { }
ServerPacket(OpcodeServer opcode, size_t initialSize=200, ConnectionType connection=CONNECTION_TYPE_DEFAULT)
Definition: Packet.h:49
Definition: Opcodes.h:897
WorldPackets::Chat::Chat::Chat ( Chat const chat)
95  : ServerPacket(SMSG_CHAT, chat._worldPacket.size()),
96  SlashCmd(chat.SlashCmd), _Language(chat._Language), SenderGUID(chat.SenderGUID),
97  SenderGuildGUID(chat.SenderGuildGUID), SenderAccountGUID(chat.SenderAccountGUID), TargetGUID(chat.TargetGUID), PartyGUID(chat.PartyGUID),
98  SenderVirtualAddress(chat.SenderVirtualAddress), TargetVirtualAddress(chat.TargetVirtualAddress), SenderName(chat.SenderName), TargetName(chat.TargetName),
99  Prefix(chat.Prefix), _Channel(chat._Channel), ChatText(chat.ChatText), AchievementID(chat.AchievementID), _ChatFlags(chat._ChatFlags),
100  DisplayTime(chat.DisplayTime), HideChatLog(chat.HideChatLog), FakeSenderName(chat.FakeSenderName)
101 {
102 }
uint8 SlashCmd
Definition: ChatPackets.h:162
ServerPacket(OpcodeServer opcode, size_t initialSize=200, ConnectionType connection=CONNECTION_TYPE_DEFAULT)
Definition: Packet.h:49
std::string SenderName
Definition: ChatPackets.h:171
uint8 _ChatFlags
Definition: ChatPackets.h:177
float DisplayTime
Definition: ChatPackets.h:178
ObjectGuid PartyGUID
Definition: ChatPackets.h:168
std::string ChatText
Definition: ChatPackets.h:175
uint32 TargetVirtualAddress
Definition: ChatPackets.h:170
ObjectGuid SenderGuildGUID
Definition: ChatPackets.h:165
bool FakeSenderName
Definition: ChatPackets.h:180
std::string Prefix
Addon Prefix.
Definition: ChatPackets.h:173
ObjectGuid SenderGUID
Definition: ChatPackets.h:164
ObjectGuid SenderAccountGUID
Definition: ChatPackets.h:166
Definition: Opcodes.h:897
ObjectGuid TargetGUID
Definition: ChatPackets.h:167
uint8 _Language
Definition: ChatPackets.h:163
uint32 AchievementID
Definition: ChatPackets.h:176
std::string TargetName
Definition: ChatPackets.h:172
std::string _Channel
Channel Name.
Definition: ChatPackets.h:174
uint32 SenderVirtualAddress
Definition: ChatPackets.h:169
bool HideChatLog
Definition: ChatPackets.h:179

Member Function Documentation

void WorldPackets::Chat::Chat::Initialize ( ChatMsg  chatType,
Language  language,
WorldObject const sender,
WorldObject const receiver,
std::string  message,
uint32  achievementId = 0,
std::string  channelName = "",
LocaleConstant  locale = DEFAULT_LOCALE,
std::string  addonPrefix = "" 
)
106 {
107  // Clear everything because same packet can be used multiple times
108  Clear();
109 
110  SenderGUID.Clear();
113  PartyGUID.Clear();
114  TargetGUID.Clear();
115  SenderName.clear();
116  TargetName.clear();
118 
119  SlashCmd = chatType;
120  _Language = language;
121 
122  if (sender)
123  SetSender(sender, locale);
124 
125  if (receiver)
126  SetReceiver(receiver, locale);
127 
130  AchievementID = achievementId;
131  _Channel = std::move(channelName);
132  Prefix = std::move(addonPrefix);
133  ChatText = std::move(message);
134 }
uint8 SlashCmd
Definition: ChatPackets.h:162
std::string SenderName
Definition: ChatPackets.h:171
uint8 _ChatFlags
Definition: ChatPackets.h:177
void SetReceiver(WorldObject const *receiver, LocaleConstant locale)
Definition: ChatPackets.cpp:155
ObjectGuid PartyGUID
Definition: ChatPackets.h:168
std::string ChatText
Definition: ChatPackets.h:175
uint32 TargetVirtualAddress
Definition: ChatPackets.h:170
ObjectGuid SenderGuildGUID
Definition: ChatPackets.h:165
void Clear()
Definition: Packet.h:53
std::string Prefix
Addon Prefix.
Definition: ChatPackets.h:173
ObjectGuid SenderGUID
Definition: ChatPackets.h:164
ObjectGuid SenderAccountGUID
Definition: ChatPackets.h:166
ObjectGuid TargetGUID
Definition: ChatPackets.h:167
uint8 _Language
Definition: ChatPackets.h:163
void Clear()
Definition: ObjectGuid.h:215
uint32 AchievementID
Definition: ChatPackets.h:176
std::string TargetName
Definition: ChatPackets.h:172
Definition: SharedDefines.h:4307
std::string _Channel
Channel Name.
Definition: ChatPackets.h:174
uint32 GetVirtualRealmAddress()
Definition: World.cpp:3487
uint32 SenderVirtualAddress
Definition: ChatPackets.h:169
void SetSender(WorldObject const *sender, LocaleConstant locale)
Definition: ChatPackets.cpp:136

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void WorldPackets::Chat::Chat::SetReceiver ( WorldObject const receiver,
LocaleConstant  locale 
)
156 {
157  TargetGUID = receiver->GetGUID();
158  if (Creature const* creatureReceiver = receiver->ToCreature())
159  TargetName = creatureReceiver->GetNameForLocaleIdx(locale);
160 }
Definition: Creature.h:467
ObjectGuid TargetGUID
Definition: ChatPackets.h:167
Creature * ToCreature()
Definition: Object.h:194
std::string TargetName
Definition: ChatPackets.h:172

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void WorldPackets::Chat::Chat::SetSender ( WorldObject const sender,
LocaleConstant  locale 
)
137 {
138  SenderGUID = sender->GetGUID();
139 
140  if (Creature const* creatureSender = sender->ToCreature())
141  SenderName = creatureSender->GetNameForLocaleIdx(locale);
142 
143  if (Player const* playerSender = sender->ToPlayer())
144  {
145  SenderAccountGUID = playerSender->GetSession()->GetAccountGUID();
146  _ChatFlags = playerSender->GetChatFlags();
147 
148  SenderGuildGUID = ObjectGuid::Create<HighGuid::Guild>(playerSender->GetGuildId());
149 
150  if (Group const* group = playerSender->GetGroup())
151  PartyGUID = group->GetGUID();
152  }
153 }
std::string SenderName
Definition: ChatPackets.h:171
uint8 _ChatFlags
Definition: ChatPackets.h:177
ObjectGuid PartyGUID
Definition: ChatPackets.h:168
ObjectGuid SenderGuildGUID
Definition: ChatPackets.h:165
Definition: Creature.h:467
ObjectGuid SenderGUID
Definition: ChatPackets.h:164
ObjectGuid SenderAccountGUID
Definition: ChatPackets.h:166
Creature * ToCreature()
Definition: Object.h:194
Definition: Group.h:191

+ Here is the call graph for this function:

WorldPacket const * WorldPackets::Chat::Chat::Write ( )
overridevirtual

Implements WorldPackets::Packet.

163 {
175  _worldPacket.WriteBits(SenderName.length(), 11);
176  _worldPacket.WriteBits(TargetName.length(), 11);
177  _worldPacket.WriteBits(Prefix.length(), 5);
178  _worldPacket.WriteBits(_Channel.length(), 7);
179  _worldPacket.WriteBits(ChatText.length(), 12);
184 
190 
191  return &_worldPacket;
192 }
uint8 SlashCmd
Definition: ChatPackets.h:162
std::string SenderName
Definition: ChatPackets.h:171
uint8 _ChatFlags
Definition: ChatPackets.h:177
float DisplayTime
Definition: ChatPackets.h:178
ObjectGuid PartyGUID
Definition: ChatPackets.h:168
std::string ChatText
Definition: ChatPackets.h:175
uint32 TargetVirtualAddress
Definition: ChatPackets.h:170
ObjectGuid SenderGuildGUID
Definition: ChatPackets.h:165
bool FakeSenderName
Definition: ChatPackets.h:180
void FlushBits()
Definition: ByteBuffer.h:150
WorldPacket _worldPacket
Definition: Packet.h:43
bool WriteBit(uint32 bit)
Definition: ByteBuffer.h:170
std::string Prefix
Addon Prefix.
Definition: ChatPackets.h:173
ObjectGuid SenderGUID
Definition: ChatPackets.h:164
ObjectGuid SenderAccountGUID
Definition: ChatPackets.h:166
void WriteString(std::string const &str)
Definition: ByteBuffer.h:540
ObjectGuid TargetGUID
Definition: ChatPackets.h:167
uint8 _Language
Definition: ChatPackets.h:163
uint32 AchievementID
Definition: ChatPackets.h:176
std::string TargetName
Definition: ChatPackets.h:172
std::string _Channel
Channel Name.
Definition: ChatPackets.h:174
uint32 SenderVirtualAddress
Definition: ChatPackets.h:169
bool HideChatLog
Definition: ChatPackets.h:179
void WriteBits(T value, int32 bits)
Definition: ByteBuffer.h:198

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

Member Data Documentation

std::string WorldPackets::Chat::Chat::_Channel

Channel Name.

uint8 WorldPackets::Chat::Chat::_ChatFlags = 0
See also
enum ChatFlags
uint8 WorldPackets::Chat::Chat::_Language = LANG_UNIVERSAL
uint32 WorldPackets::Chat::Chat::AchievementID = 0
std::string WorldPackets::Chat::Chat::ChatText
float WorldPackets::Chat::Chat::DisplayTime = 0.0f
bool WorldPackets::Chat::Chat::FakeSenderName = false
bool WorldPackets::Chat::Chat::HideChatLog = false
ObjectGuid WorldPackets::Chat::Chat::PartyGUID
std::string WorldPackets::Chat::Chat::Prefix

Addon Prefix.

ObjectGuid WorldPackets::Chat::Chat::SenderAccountGUID
ObjectGuid WorldPackets::Chat::Chat::SenderGUID
ObjectGuid WorldPackets::Chat::Chat::SenderGuildGUID
std::string WorldPackets::Chat::Chat::SenderName
uint32 WorldPackets::Chat::Chat::SenderVirtualAddress = 0
uint8 WorldPackets::Chat::Chat::SlashCmd = 0
See also
enum ChatMsg
ObjectGuid WorldPackets::Chat::Chat::TargetGUID
std::string WorldPackets::Chat::Chat::TargetName
uint32 WorldPackets::Chat::Chat::TargetVirtualAddress = 0

The documentation for this class was generated from the following files: