TrinityCore
Loading...
Searching...
No Matches
ChannelAppenders.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 _CHANNELAPPENDERS_H
19#define _CHANNELAPPENDERS_H
20
21#include "Channel.h"
22#include "CharacterCache.h"
23#include "World.h"
24#include "WorldPacket.h"
25
26// initial packet data (notify type and channel name)
27template<class PacketModifier>
29{
30 public:
31 ChannelNameBuilder(Channel const* source, PacketModifier const& modifier)
32 : _source(source), _modifier(modifier){ }
33
34 void operator()(WorldPacket& data, LocaleConstant locale) const
35 {
36 // LocalizedPacketDo sends client DBC locale, we need to get available to server locale
37 LocaleConstant localeIdx = sWorld->GetAvailableDbcLocale(locale);
38
39 data.Initialize(SMSG_CHANNEL_NOTIFY, 60); // guess size
40 data << uint8(_modifier.NotificationType);
41 data << _source->GetName(localeIdx);
42 _modifier.Append(data);
43 }
44
45 private:
47 PacketModifier _modifier;
48};
49
51{
52 explicit JoinedAppend(ObjectGuid const& guid) : _guid(guid) { }
53
55
56 void Append(WorldPacket& data) const
57 {
58 data << _guid;
59 }
60
61private:
63};
64
66{
67 explicit LeftAppend(ObjectGuid const& guid) : _guid(guid) { }
68
70
71 void Append(WorldPacket& data) const
72 {
73 data << _guid;
74 }
75
76private:
78};
79
81{
82 explicit YouJoinedAppend(Channel const* channel) : _channel(channel) { }
83
85
86 void Append(WorldPacket& data) const
87 {
88 data << uint8(_channel->GetFlags());
89 data << uint32(_channel->GetChannelId());
90 data << uint32(0);
91 }
92
93private:
95};
96
98{
99 explicit YouLeftAppend(Channel const* channel) : _channel(channel) { }
100
102
103 void Append(WorldPacket& data) const
104 {
105 data << uint32(_channel->GetChannelId());
106 data << uint8(_channel->IsConstant());
107 }
108
109private:
111};
112
114{
116
117 void Append(WorldPacket& /*data*/) const { }
118};
119
121{
123
124 void Append(WorldPacket& /*data*/) const { }
125};
126
128{
130
131 void Append(WorldPacket& /*data*/) const { }
132};
133
135{
136 explicit PasswordChangedAppend(ObjectGuid const& guid) : _guid(guid) { }
137
139
140 void Append(WorldPacket& data) const
141 {
142 data << _guid;
143 }
144
145private:
147};
148
150{
151 explicit OwnerChangedAppend(ObjectGuid const& guid) : _guid(guid) { }
152
154
155 void Append(WorldPacket& data) const
156 {
157 data << _guid;
158 }
159
160private:
162};
163
165{
166 explicit PlayerNotFoundAppend(std::string const& playerName) : _playerName(playerName) { }
167
169
170 void Append(WorldPacket& data) const
171 {
172 data << _playerName;
173 }
174
175private:
176 std::string _playerName;
177};
178
180{
182
183 void Append(WorldPacket& /*data*/) const { }
184};
185
187{
188 explicit ChannelOwnerAppend(Channel const* channel, ObjectGuid const& ownerGuid) : _channel(channel), _ownerGuid(ownerGuid)
189 {
190 if (CharacterCacheEntry const* cInfo = sCharacterCache->GetCharacterCacheByGuid(_ownerGuid))
191 _ownerName = cInfo->Name;
192 }
193
195
196 void Append(WorldPacket& data) const
197 {
198 data << ((_channel->IsConstant() || !_ownerGuid) ? "Nobody" : _ownerName);
199 }
200
201private:
204
205 std::string _ownerName;
206};
207
209{
210 explicit ModeChangeAppend(ObjectGuid const& guid, uint8 oldFlags, uint8 newFlags) : _guid(guid), _oldFlags(oldFlags), _newFlags(newFlags) { }
211
213
214 void Append(WorldPacket& data) const
215 {
216 data << _guid;
217 data << uint8(_oldFlags);
218 data << uint8(_newFlags);
219 }
220
221private:
225};
226
228{
229 explicit AnnouncementsOnAppend(ObjectGuid const& guid) : _guid(guid) { }
230
232
233 void Append(WorldPacket& data) const
234 {
235 data << _guid;
236 }
237
238private:
240};
241
243{
244 explicit AnnouncementsOffAppend(ObjectGuid const& guid) : _guid(guid) { }
245
247
248 void Append(WorldPacket& data) const
249 {
250 data << _guid;
251 }
252
253private:
255};
256
258{
260
261 void Append(WorldPacket& /*data*/) const { }
262};
263
265{
266 explicit PlayerKickedAppend(ObjectGuid const& kicker, ObjectGuid const& kickee) : _kicker(kicker), _kickee(kickee) { }
267
269
270 void Append(WorldPacket& data) const
271 {
272 data << _kickee;
273 data << _kicker;
274 }
275
276private:
279};
280
282{
284
285 void Append(WorldPacket& /*data*/) const { }
286};
287
289{
290 explicit PlayerBannedAppend(ObjectGuid const& moderator, ObjectGuid const& banned) : _moderator(moderator), _banned(banned) { }
291
293
294 void Append(WorldPacket& data) const
295 {
296 data << _banned;
297 data << _moderator;
298 }
299
300private:
303};
304
306{
307 explicit PlayerUnbannedAppend(ObjectGuid const& moderator, ObjectGuid const& unbanned) : _moderator(moderator), _unbanned(unbanned) { }
308
310
311 void Append(WorldPacket& data) const
312 {
313 data << _unbanned;
314 data << _moderator;
315 }
316
317private:
320};
321
323{
324 explicit PlayerNotBannedAppend(std::string const& playerName) : _playerName(playerName) { }
325
327
328 void Append(WorldPacket& data) const
329 {
330 data << _playerName;
331 }
332
333private:
334 std::string _playerName;
335};
336
338{
339 explicit PlayerAlreadyMemberAppend(ObjectGuid const& guid) : _guid(guid) { }
340
342
343 void Append(WorldPacket& data) const
344 {
345 data << _guid;
346 }
347
348private:
350};
351
353{
354 explicit InviteAppend(ObjectGuid const& guid) : _guid(guid) { }
355
357
358 void Append(WorldPacket& data) const
359 {
360 data << _guid;
361 }
362
363private:
365};
366
373
375{
377
378 void Append(WorldPacket& /*data*/) const { }
379};
380
382{
384
385 void Append(WorldPacket& /*data*/) const { }
386};
387
389{
391
392 void Append(WorldPacket& /*data*/) const { }
393};
394
396{
397 explicit PlayerInvitedAppend(std::string const& playerName) : _playerName(playerName) { }
398
400
401 void Append(WorldPacket& data) const
402 {
403 data << _playerName;
404 }
405
406private:
407 std::string _playerName;
408};
409
411{
412 explicit PlayerInviteBannedAppend(std::string const& playerName) : _playerName(playerName) { }
413
415
416 void Append(WorldPacket& data) const
417 {
418 data << _playerName;
419 }
420
421private:
422 std::string _playerName;
423};
424
426{
428
429 void Append(WorldPacket& /*data*/) const { }
430};
431
433{
435
436 void Append(WorldPacket& /*data*/) const { }
437};
438
440{
442
443 void Append(WorldPacket& /*data*/) const { }
444};
445
447{
448 explicit VoiceOnAppend(ObjectGuid const& guid) : _guid(guid) { }
449
451
452 void Append(WorldPacket& data) const
453 {
454 data << _guid;
455 }
456
457private:
459};
460
462{
463 explicit VoiceOffAppend(ObjectGuid const& guid) : _guid(guid) { }
464
466
467 void Append(WorldPacket& data) const
468 {
469 data << _guid;
470 }
471
472private:
474};
475
476#endif // _CHANNELAPPENDERS_H
@ CHAT_YOU_JOINED_NOTICE
Definition Channel.h:36
@ CHAT_WRONG_FACTION_NOTICE
Definition Channel.h:61
@ CHAT_NOT_MODERATOR_NOTICE
Definition Channel.h:41
@ CHAT_PLAYER_UNBANNED_NOTICE
Definition Channel.h:56
@ CHAT_PLAYER_NOT_FOUND_NOTICE
Definition Channel.h:44
@ CHAT_MUTED_NOTICE
Definition Channel.h:52
@ CHAT_PLAYER_NOT_BANNED_NOTICE
Definition Channel.h:57
@ CHAT_PLAYER_INVITED_NOTICE
Definition Channel.h:64
@ CHAT_PLAYER_KICKED_NOTICE
Definition Channel.h:53
@ CHAT_VOICE_OFF_NOTICE
Definition Channel.h:70
@ CHAT_MODE_CHANGE_NOTICE
Definition Channel.h:47
@ CHAT_NOT_MEMBER_NOTICE
Definition Channel.h:40
@ CHAT_ANNOUNCEMENTS_ON_NOTICE
Definition Channel.h:48
@ CHAT_JOINED_NOTICE
Definition Channel.h:33
@ CHAT_LEFT_NOTICE
Definition Channel.h:34
@ CHAT_INVITE_WRONG_FACTION_NOTICE
Definition Channel.h:60
@ CHAT_BANNED_NOTICE
Definition Channel.h:54
@ CHAT_PLAYER_BANNED_NOTICE
Definition Channel.h:55
@ CHAT_PLAYER_ALREADY_MEMBER_NOTICE
Definition Channel.h:58
@ CHAT_OWNER_CHANGED_NOTICE
Definition Channel.h:43
@ CHAT_ANNOUNCEMENTS_OFF_NOTICE
Definition Channel.h:49
@ CHAT_VOICE_ON_NOTICE
Definition Channel.h:69
@ CHAT_NOT_IN_LFG_NOTICE
Definition Channel.h:68
@ CHAT_NOT_IN_AREA_NOTICE
Definition Channel.h:67
@ CHAT_NOT_MODERATED_NOTICE
Definition Channel.h:63
@ CHAT_YOU_LEFT_NOTICE
Definition Channel.h:38
@ CHAT_CHANNEL_OWNER_NOTICE
Definition Channel.h:46
@ CHAT_WRONG_PASSWORD_NOTICE
Definition Channel.h:39
@ CHAT_THROTTLED_NOTICE
Definition Channel.h:66
@ CHAT_PLAYER_INVITE_BANNED_NOTICE
Definition Channel.h:65
@ CHAT_INVITE_NOTICE
Definition Channel.h:59
@ CHAT_NOT_OWNER_NOTICE
Definition Channel.h:45
@ CHAT_PASSWORD_CHANGED_NOTICE
Definition Channel.h:42
@ CHAT_INVALID_NAME_NOTICE
Definition Channel.h:62
#define sCharacterCache
LocaleConstant
Definition Common.h:48
uint8_t uint8
Definition Define.h:135
uint32_t uint32
Definition Define.h:133
ChannelNameBuilder(Channel const *source, PacketModifier const &modifier)
PacketModifier _modifier
void operator()(WorldPacket &data, LocaleConstant locale) const
Channel const * _source
bool IsConstant() const
Definition Channel.h:169
std::string GetName(LocaleConstant locale=DEFAULT_LOCALE) const
Definition Channel.cpp:108
uint32 GetChannelId() const
Definition Channel.h:168
uint8 GetFlags() const
Definition Channel.h:184
void Initialize(uint16 opcode, size_t newres=200)
Definition WorldPacket.h:73
@ SMSG_CHANNEL_NOTIFY
Definition Opcodes.h:182
#define sWorld
Definition World.h:900
AnnouncementsOffAppend(ObjectGuid const &guid)
void Append(WorldPacket &data) const
static uint8 const NotificationType
void Append(WorldPacket &data) const
AnnouncementsOnAppend(ObjectGuid const &guid)
static uint8 const NotificationType
static uint8 const NotificationType
void Append(WorldPacket &) const
ChannelOwnerAppend(Channel const *channel, ObjectGuid const &ownerGuid)
Channel const * _channel
void Append(WorldPacket &data) const
static uint8 const NotificationType
static uint8 const NotificationType
void Append(WorldPacket &) const
void Append(WorldPacket &data) const
InviteAppend(ObjectGuid const &guid)
static uint8 const NotificationType
void Append(WorldPacket &) const
static uint8 const NotificationType
void Append(WorldPacket &data) const
JoinedAppend(ObjectGuid const &guid)
ObjectGuid _guid
static uint8 const NotificationType
void Append(WorldPacket &data) const
LeftAppend(ObjectGuid const &guid)
ObjectGuid _guid
static uint8 const NotificationType
static uint8 const NotificationType
void Append(WorldPacket &data) const
ModeChangeAppend(ObjectGuid const &guid, uint8 oldFlags, uint8 newFlags)
static uint8 const NotificationType
void Append(WorldPacket &) const
void Append(WorldPacket &) const
static uint8 const NotificationType
void Append(WorldPacket &) const
static uint8 const NotificationType
void Append(WorldPacket &) const
static uint8 const NotificationType
void Append(WorldPacket &) const
static uint8 const NotificationType
void Append(WorldPacket &) const
static uint8 const NotificationType
void Append(WorldPacket &) const
static uint8 const NotificationType
OwnerChangedAppend(ObjectGuid const &guid)
void Append(WorldPacket &data) const
static uint8 const NotificationType
void Append(WorldPacket &data) const
PasswordChangedAppend(ObjectGuid const &guid)
static uint8 const NotificationType
PlayerAlreadyMemberAppend(ObjectGuid const &guid)
void Append(WorldPacket &data) const
static uint8 const NotificationType
static uint8 const NotificationType
PlayerBannedAppend(ObjectGuid const &moderator, ObjectGuid const &banned)
void Append(WorldPacket &data) const
void Append(WorldPacket &data) const
static uint8 const NotificationType
PlayerInviteBannedAppend(std::string const &playerName)
static uint8 const NotificationType
void Append(WorldPacket &data) const
PlayerInvitedAppend(std::string const &playerName)
void Append(WorldPacket &data) const
PlayerKickedAppend(ObjectGuid const &kicker, ObjectGuid const &kickee)
static uint8 const NotificationType
void Append(WorldPacket &data) const
static uint8 const NotificationType
PlayerNotBannedAppend(std::string const &playerName)
PlayerNotFoundAppend(std::string const &playerName)
void Append(WorldPacket &data) const
static uint8 const NotificationType
static uint8 const NotificationType
void Append(WorldPacket &data) const
PlayerUnbannedAppend(ObjectGuid const &moderator, ObjectGuid const &unbanned)
void Append(WorldPacket &) const
static uint8 const NotificationType
void Append(WorldPacket &data) const
static uint8 const NotificationType
VoiceOffAppend(ObjectGuid const &guid)
static uint8 const NotificationType
VoiceOnAppend(ObjectGuid const &guid)
void Append(WorldPacket &data) const
void Append(WorldPacket &) const
static uint8 const NotificationType
static uint8 const NotificationType
void Append(WorldPacket &) const
Channel const * _channel
void Append(WorldPacket &data) const
static uint8 const NotificationType
YouJoinedAppend(Channel const *channel)
static uint8 const NotificationType
void Append(WorldPacket &data) const
Channel const * _channel
YouLeftAppend(Channel const *channel)