TrinityCore
ChatPackets.h
Go to the documentation of this file.
1/*
2 * This file is part of the TrinityCore Project. See AUTHORS file for Copyright information
3 *
4 * This program is free software; you can redistribute it and/or modify it
5 * under the terms of the GNU General Public License as published by the
6 * Free Software Foundation; either version 2 of the License, or (at your
7 * option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
12 * more details.
13 *
14 * You should have received a copy of the GNU General Public License along
15 * with this program. If not, see <http://www.gnu.org/licenses/>.
16 */
17
18#ifndef ChatPackets_h__
19#define ChatPackets_h__
20
21#include "Packet.h"
22#include "Common.h"
23#include "ObjectGuid.h"
24#include "Optional.h"
25#include "PacketUtilities.h"
26#include "SharedDefines.h"
27
28class WorldObject;
30
31namespace WorldPackets
32{
33 namespace Chat
34 {
35 // CMSG_CHAT_MESSAGE_GUILD
36 // CMSG_CHAT_MESSAGE_OFFICER
37 // CMSG_CHAT_MESSAGE_YELL
38 // CMSG_CHAT_MESSAGE_SAY
39 // CMSG_CHAT_MESSAGE_PARTY
40 // CMSG_CHAT_MESSAGE_RAID
41 // CMSG_CHAT_MESSAGE_RAID_WARNING
42 // CMSG_CHAT_MESSAGE_INSTANCE_CHAT
43 class ChatMessage final : public ClientPacket
44 {
45 public:
46 ChatMessage(WorldPacket&& packet) : ClientPacket(std::move(packet)) { }
47
48 void Read() override;
49
50 std::string Text;
52 bool IsSecure = true;
53 };
54
55 // CMSG_CHAT_MESSAGE_WHISPER
56 class ChatMessageWhisper final : public ClientPacket
57 {
58 public:
60
61 void Read() override;
62
64 std::string Text;
65 std::string Target;
66 };
67
68 // CMSG_CHAT_MESSAGE_CHANNEL
69 class ChatMessageChannel final : public ClientPacket
70 {
71 public:
73
74 void Read() override;
75
78 std::string Text;
79 std::string Target;
81 };
82
84 {
85 std::string Prefix;
86 std::string Text;
88 bool IsLogged = false;
89 };
90
91 // CMSG_CHAT_ADDON_MESSAGE
92 class ChatAddonMessage final : public ClientPacket
93 {
94 public:
96
97 void Read() override;
98
100 };
101
102 // CMSG_CHAT_ADDON_MESSAGE_CHANNEL
104 {
105 public:
107 {
108 ChannelGUID.emplace();
109 }
110
111 void Read() override;
112
113 std::string Target;
115 Optional<ObjectGuid> ChannelGUID; // not optional in the packet. Optional for api reasons
116 };
117
118 class ChatMessageDND final : public ClientPacket
119 {
120 public:
122
123 void Read() override;
124
125 std::string Text;
126 };
127
128 class ChatMessageAFK final : public ClientPacket
129 {
130 public:
132
133 void Read() override;
134
135 std::string Text;
136 };
137
138 class ChatMessageEmote final : public ClientPacket
139 {
140 public:
142
143 void Read() override;
144
145 std::string Text;
146 };
147
148 // SMSG_CHAT
149 class TC_GAME_API Chat final : public ServerPacket
150 {
151 public:
153 Chat(Chat const& chat);
154
155 void Initialize(ChatMsg chatType, Language language, WorldObject const* sender, WorldObject const* receiver, std::string_view message, uint32 achievementId = 0,
156 std::string_view channelName = "", LocaleConstant locale = DEFAULT_LOCALE, std::string_view addonPrefix = "");
157 void SetSender(WorldObject const* sender, LocaleConstant locale);
158 void SetReceiver(WorldObject const* receiver, LocaleConstant locale);
159
160 WorldPacket const* Write() override;
161
162 uint8 SlashCmd = 0;
168 uint32 SenderVirtualAddress = 0;
169 uint32 TargetVirtualAddress = 0;
170 std::string SenderName;
171 std::string TargetName;
172 std::string Prefix;
173 std::string _Channel;
174 std::string ChatText;
175 uint32 AchievementID = 0;
176 uint16 _ChatFlags = 0;
177 float DisplayTime = 0.0f;
178 int32 SpellID = 0;
180 bool HideChatLog = false;
181 bool FakeSenderName = false;
183 };
184
185 class Emote final : public ServerPacket
186 {
187 public:
189
190 WorldPacket const* Write() override;
191
194 std::vector<int32> SpellVisualKitIDs;
196 };
197
198 class CTextEmote final : public ClientPacket
199 {
200 public:
202
203 void Read() override;
204
210 };
211
212 class STextEmote final : public ServerPacket
213 {
214 public:
215 STextEmote() : ServerPacket(SMSG_TEXT_EMOTE, 3 * 18 + 2 * 4) { }
216
217 WorldPacket const* Write() override;
218
224 };
225
226 class ClearBossEmotes final : public ServerPacket
227 {
228 public:
230
231 WorldPacket const* Write() override { return &_worldPacket; }
232 };
233
235 {
236 public:
237 PrintNotification(std::string const& notifyText) : ServerPacket(SMSG_PRINT_NOTIFICATION, 2 + notifyText.size()), NotifyText(notifyText) { }
238
239 WorldPacket const* Write() override;
240
241 std::string NotifyText;
242 };
243
244 class EmoteClient final : public ClientPacket
245 {
246 public:
247 EmoteClient(WorldPacket&& packet) : ClientPacket(CMSG_EMOTE, std::move(packet)) { }
248
249 void Read() override { }
250 };
251
252 class ChatPlayerNotfound final : public ServerPacket
253 {
254 public:
255 ChatPlayerNotfound(std::string const& name) : ServerPacket(SMSG_CHAT_PLAYER_NOTFOUND, 2 + name.size()), Name(name) { }
256
257 WorldPacket const* Write() override;
258
259 std::string Name;
260 };
261
262 class ChatServerMessage final : public ServerPacket
263 {
264 public:
266
267 WorldPacket const* Write() override;
268
270 std::string_view StringParam;
271 };
272
274 {
275 public:
276 enum
277 {
278 MAX_PREFIXES = 64
279 };
280
282
283 void Read() override;
284
286 };
287
289 {
290 public:
292
293 void Read() override { }
294 };
295
296 class DefenseMessage final : public ServerPacket
297 {
298 public:
300
301 WorldPacket const* Write() override;
302
304 std::string MessageText;
305 };
306
307 class ChatReportIgnored final : public ClientPacket
308 {
309 public:
311
312 void Read() override;
313
316 };
317
319 {
320 public:
321 ChatPlayerAmbiguous(std::string const& name) : ServerPacket(SMSG_CHAT_PLAYER_AMBIGUOUS, 2 + name.length()), Name(name) { }
322
323 WorldPacket const* Write() override;
324
325 std::string Name;
326 };
327
328 class ChatRestricted final : public ServerPacket
329 {
330 public:
332
333 WorldPacket const* Write() override;
334
336 };
337
339 {
340 public:
342
343 void Read() override;
344
346 };
347
349 {
350 public:
352
353 WorldPacket const* Write() override;
354
357 };
358
359 class UpdateAADCStatus final : public ClientPacket
360 {
361 public:
363
364 void Read() override;
365
366 bool ChatDisabled = false;
367 };
368
370 {
371 public:
373
374 WorldPacket const* Write() override;
375
376 bool Success = false;
377 bool ChatDisabled = false;
378 };
379 }
380}
381
382#endif // ChatPackets_h__
ChatWhisperTargetStatus
Definition: ChatHandler.cpp:47
LocaleConstant
Definition: Common.h:48
#define DEFAULT_LOCALE
Definition: Common.h:66
#define TC_GAME_API
Definition: Define.h:123
uint8_t uint8
Definition: Define.h:144
int32_t int32
Definition: Define.h:138
uint16_t uint16
Definition: Define.h:143
uint32_t uint32
Definition: Define.h:142
std::optional< T > Optional
Optional helper class to wrap optional values within.
Definition: Optional.h:25
Language
@ LANG_UNIVERSAL
ChatMsg
@ CHAT_MSG_PARTY
Array< int32, 2 > SpellVisualKitIDs
Definition: ChatPackets.h:208
CTextEmote(WorldPacket &&packet)
Definition: ChatPackets.h:201
ChatAddonMessageTargeted(WorldPacket &&packet)
Definition: ChatPackets.h:106
ChatAddonMessage(WorldPacket &&packet)
Definition: ChatPackets.h:95
ChatAddonMessageParams Params
Definition: ChatPackets.h:99
ChatMessageAFK(WorldPacket &&packet)
Definition: ChatPackets.h:131
ChatMessageChannel(WorldPacket &&packet)
Definition: ChatPackets.h:72
ChatMessageDND(WorldPacket &&packet)
Definition: ChatPackets.h:121
ChatMessageEmote(WorldPacket &&packet)
Definition: ChatPackets.h:141
ChatMessageWhisper(WorldPacket &&packet)
Definition: ChatPackets.h:59
ChatMessage(WorldPacket &&packet)
Definition: ChatPackets.h:46
WorldPacket const * Write() override
ChatPlayerAmbiguous(std::string const &name)
Definition: ChatPackets.h:321
WorldPacket const * Write() override
ChatPlayerNotfound(std::string const &name)
Definition: ChatPackets.h:255
Array< std::string, MAX_PREFIXES > Prefixes
Definition: ChatPackets.h:285
ChatReportIgnored(WorldPacket &&packet)
Definition: ChatPackets.h:310
WorldPacket const * Write() override
WorldPacket const * Write() override
Optional< ObjectGuid > ChannelGUID
Definition: ChatPackets.h:182
std::string Prefix
Addon Prefix.
Definition: ChatPackets.h:172
ObjectGuid SenderAccountGUID
Definition: ChatPackets.h:166
Optional< uint32 > Unused_801
Definition: ChatPackets.h:179
std::string _Channel
Channel Name.
Definition: ChatPackets.h:173
WorldPacket const * Write() override
Definition: ChatPackets.h:231
WorldPacket const * Write() override
EmoteClient(WorldPacket &&packet)
Definition: ChatPackets.h:247
WorldPacket const * Write() override
std::vector< int32 > SpellVisualKitIDs
Definition: ChatPackets.h:194
PrintNotification(std::string const &notifyText)
Definition: ChatPackets.h:237
WorldPacket const * Write() override
WorldPacket const * Write() override
UpdateAADCStatus(WorldPacket &&packet)
Definition: ChatPackets.h:362
WorldPacket _worldPacket
Definition: Packet.h:43
@ CMSG_CHAT_MESSAGE_WHISPER
Definition: Opcodes.h:228
@ CMSG_CHAT_ADDON_MESSAGE_TARGETED
Definition: Opcodes.h:198
@ CMSG_CHAT_MESSAGE_EMOTE
Definition: Opcodes.h:220
@ CMSG_CHAT_MESSAGE_CHANNEL
Definition: Opcodes.h:218
@ CMSG_SEND_TEXT_EMOTE
Definition: Opcodes.h:761
@ CMSG_CHAT_REPORT_IGNORED
Definition: Opcodes.h:232
@ CMSG_EMOTE
Definition: Opcodes.h:333
@ CMSG_CHAT_MESSAGE_AFK
Definition: Opcodes.h:217
@ CMSG_CHAT_UNREGISTER_ALL_ADDON_PREFIXES
Definition: Opcodes.h:233
@ CMSG_CHAT_MESSAGE_DND
Definition: Opcodes.h:219
@ CMSG_CHAT_CAN_LOCAL_WHISPER_TARGET_REQUEST
Definition: Opcodes.h:199
@ CMSG_CHAT_ADDON_MESSAGE
Definition: Opcodes.h:197
@ CMSG_UPDATE_AADC_STATUS
Definition: Opcodes.h:869
@ CMSG_CHAT_REGISTER_ADDON_PREFIXES
Definition: Opcodes.h:230
@ SMSG_DEFENSE_MESSAGE
Definition: Opcodes.h:1196
@ SMSG_CLEAR_BOSS_EMOTES
Definition: Opcodes.h:1126
@ SMSG_CHAT_SERVER_MESSAGE
Definition: Opcodes.h:1118
@ SMSG_UPDATE_AADC_STATUS_RESPONSE
Definition: Opcodes.h:2022
@ SMSG_CHAT
Definition: Opcodes.h:1106
@ SMSG_EMOTE
Definition: Opcodes.h:1223
@ SMSG_TEXT_EMOTE
Definition: Opcodes.h:1993
@ SMSG_CHAT_RESTRICTED
Definition: Opcodes.h:1117
@ SMSG_CHAT_PLAYER_AMBIGUOUS
Definition: Opcodes.h:1113
@ SMSG_PRINT_NOTIFICATION
Definition: Opcodes.h:1762
@ SMSG_CHAT_PLAYER_NOTFOUND
Definition: Opcodes.h:1114
@ SMSG_CHAT_CAN_LOCAL_WHISPER_TARGET_RESPONSE
Definition: Opcodes.h:1108
constexpr std::size_t size()
Definition: UpdateField.h:796
STL namespace.