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 "ChannelPackets.h"
23#include "CharacterCache.h"
24#include "World.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
40 channelNotify.Type = _modifier.NotificationType;
41 channelNotify._Channel = _source->GetName(localeIdx);
42 _modifier.Append(channelNotify);
43 channelNotify.Write();
44
45 data = channelNotify.Move();
46 }
47
48 private:
50 PacketModifier _modifier;
51};
52
54{
55 explicit JoinedAppend(ObjectGuid const& guid) : _guid(guid) { }
56
58
60 {
61 data.SenderGuid = _guid;
62 }
63
64private:
66};
67
69{
70 explicit LeftAppend(ObjectGuid const& guid) : _guid(guid) { }
71
73
75 {
76 data.SenderGuid = _guid;
77 }
78
79private:
81};
82
84{
85 explicit YouJoinedAppend(Channel const* channel) : _channel(channel) { }
86
88
90 {
91 data.NewFlags = _channel->GetFlags();
93 data.InstanceID = 0;
94 }
95
96private:
98};
99
101{
102 explicit YouLeftAppend(Channel const* channel, bool suspend) : _channel(channel), _suspend(suspend) { }
103
105
107 {
109 data.Suspended = _suspend;
110 }
111
112private:
115};
116
123
130
137
139{
140 explicit PasswordChangedAppend(ObjectGuid const& guid) : _guid(guid) { }
141
143
145 {
146 data.SenderGuid = _guid;
147 }
148
149private:
151};
152
154{
155 explicit OwnerChangedAppend(ObjectGuid const& guid) : _guid(guid) { }
156
158
160 {
161 data.SenderGuid = _guid;
162 }
163
164private:
166};
167
169{
170 explicit PlayerNotFoundAppend(std::string const& playerName) : _playerName(playerName) { }
171
173
175 {
176 data.Sender = _playerName;
177 }
178
179private:
180 std::string _playerName;
181};
182
189
191{
192 explicit ChannelOwnerAppend(Channel const* channel, ObjectGuid const& ownerGuid) : _channel(channel), _ownerGuid(ownerGuid)
193 {
194 if (CharacterCacheEntry const* cInfo = sCharacterCache->GetCharacterCacheByGuid(_ownerGuid))
195 _ownerName = cInfo->Name;
196 }
197
199
201 {
202 data.Sender = ((_channel->IsConstant() || !_ownerGuid) ? "Nobody" : _ownerName);
203 }
204
205private:
208
209 std::string _ownerName;
210};
211
213{
214 explicit ModeChangeAppend(ObjectGuid const& guid, uint8 oldFlags, uint8 newFlags) : _guid(guid), _oldFlags(oldFlags), _newFlags(newFlags) { }
215
217
219 {
220 data.SenderGuid = _guid;
221 data.OldFlags = _oldFlags;
222 data.NewFlags = _newFlags;
223 }
224
225private:
229};
230
232{
233 explicit AnnouncementsOnAppend(ObjectGuid const& guid) : _guid(guid) { }
234
236
238 {
239 data.SenderGuid = _guid;
240 }
241
242private:
244};
245
247{
248 explicit AnnouncementsOffAppend(ObjectGuid const& guid) : _guid(guid) { }
249
251
253 {
254 data.SenderGuid = _guid;
255 }
256
257private:
259};
260
262{
264
266};
267
269{
270 explicit PlayerKickedAppend(ObjectGuid const& kicker, ObjectGuid const& kickee) : _kicker(kicker), _kickee(kickee) { }
271
273
275 {
276 data.SenderGuid = _kicker;
277 data.TargetGuid = _kickee;
278 }
279
280private:
283};
284
286{
288
290};
291
293{
294 explicit PlayerBannedAppend(ObjectGuid const& moderator, ObjectGuid const& banned) : _moderator(moderator), _banned(banned) { }
295
297
299 {
300 data.SenderGuid = _moderator;
301 data.TargetGuid = _banned;
302 }
303
304private:
307};
308
310{
311 explicit PlayerUnbannedAppend(ObjectGuid const& moderator, ObjectGuid const& unbanned) : _moderator(moderator), _unbanned(unbanned) { }
312
314
316 {
317 data.SenderGuid = _moderator;
318 data.TargetGuid = _unbanned;
319 }
320
321private:
324};
325
327{
328 explicit PlayerNotBannedAppend(std::string const& playerName) : _playerName(playerName) { }
329
331
333 {
334 data.Sender = _playerName;
335 }
336
337private:
338 std::string _playerName;
339};
340
342{
343 explicit PlayerAlreadyMemberAppend(ObjectGuid const& guid) : _guid(guid) { }
344
346
348 {
349 data.SenderGuid = _guid;
350 }
351
352private:
354};
355
357{
358 explicit InviteAppend(ObjectGuid const& guid) : _guid(guid) { }
359
361
363 {
364 data.SenderGuid = _guid;
365 }
366
367private:
369};
370
377
384
391
398
400{
401 explicit PlayerInvitedAppend(std::string const& playerName) : _playerName(playerName) { }
402
404
406 {
407 data.Sender = _playerName;
408 }
409
410private:
411 std::string _playerName;
412};
413
415{
416 explicit PlayerInviteBannedAppend(std::string const& playerName) : _playerName(playerName) { }
417
419
421 {
422 data.Sender = _playerName;
423 }
424
425private:
426 std::string _playerName;
427};
428
435
442
449
451{
452 explicit VoiceOnAppend(ObjectGuid const& guid) : _guid(guid) { }
453
455
457 {
458 data.SenderGuid = _guid;
459 }
460
461private:
463};
464
466{
467 explicit VoiceOffAppend(ObjectGuid const& guid) : _guid(guid) { }
468
470
472 {
473 data.SenderGuid = _guid;
474 }
475
476private:
478};
479
480#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
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:179
std::string GetName(LocaleConstant locale=DEFAULT_LOCALE) const
Definition Channel.cpp:105
uint32 GetChannelId() const
Definition Channel.h:178
uint8 GetFlags() const
Definition Channel.h:194
std::string _Channel
Channel Name.
WorldPacket const * Write() override
WorldPacket && Move()
Definition Packet.h:53
#define sWorld
Definition World.h:901
AnnouncementsOffAppend(ObjectGuid const &guid)
void Append(WorldPackets::Channel::ChannelNotify &data) const
static uint8 const NotificationType
AnnouncementsOnAppend(ObjectGuid const &guid)
void Append(WorldPackets::Channel::ChannelNotify &data) const
static uint8 const NotificationType
void Append(WorldPackets::Channel::ChannelNotify &) const
static uint8 const NotificationType
void Append(WorldPackets::Channel::ChannelNotify &data) const
ChannelOwnerAppend(Channel const *channel, ObjectGuid const &ownerGuid)
Channel const * _channel
static uint8 const NotificationType
void Append(WorldPackets::Channel::ChannelNotify &) const
static uint8 const NotificationType
void Append(WorldPackets::Channel::ChannelNotify &data) const
InviteAppend(ObjectGuid const &guid)
static uint8 const NotificationType
void Append(WorldPackets::Channel::ChannelNotify &) const
static uint8 const NotificationType
void Append(WorldPackets::Channel::ChannelNotify &data) const
JoinedAppend(ObjectGuid const &guid)
ObjectGuid _guid
static uint8 const NotificationType
LeftAppend(ObjectGuid const &guid)
ObjectGuid _guid
void Append(WorldPackets::Channel::ChannelNotify &data) const
static uint8 const NotificationType
static uint8 const NotificationType
void Append(WorldPackets::Channel::ChannelNotify &data) const
ModeChangeAppend(ObjectGuid const &guid, uint8 oldFlags, uint8 newFlags)
void Append(WorldPackets::Channel::ChannelNotify &) const
static uint8 const NotificationType
void Append(WorldPackets::Channel::ChannelNotify &) const
static uint8 const NotificationType
static uint8 const NotificationType
void Append(WorldPackets::Channel::ChannelNotify &) const
void Append(WorldPackets::Channel::ChannelNotify &) const
static uint8 const NotificationType
void Append(WorldPackets::Channel::ChannelNotify &) const
static uint8 const NotificationType
void Append(WorldPackets::Channel::ChannelNotify &) const
static uint8 const NotificationType
static uint8 const NotificationType
void Append(WorldPackets::Channel::ChannelNotify &) const
OwnerChangedAppend(ObjectGuid const &guid)
void Append(WorldPackets::Channel::ChannelNotify &data) const
static uint8 const NotificationType
PasswordChangedAppend(ObjectGuid const &guid)
static uint8 const NotificationType
void Append(WorldPackets::Channel::ChannelNotify &data) const
void Append(WorldPackets::Channel::ChannelNotify &data) const
PlayerAlreadyMemberAppend(ObjectGuid const &guid)
static uint8 const NotificationType
static uint8 const NotificationType
void Append(WorldPackets::Channel::ChannelNotify &data) const
PlayerBannedAppend(ObjectGuid const &moderator, ObjectGuid const &banned)
void Append(WorldPackets::Channel::ChannelNotify &data) const
static uint8 const NotificationType
PlayerInviteBannedAppend(std::string const &playerName)
static uint8 const NotificationType
void Append(WorldPackets::Channel::ChannelNotify &data) const
PlayerInvitedAppend(std::string const &playerName)
PlayerKickedAppend(ObjectGuid const &kicker, ObjectGuid const &kickee)
static uint8 const NotificationType
void Append(WorldPackets::Channel::ChannelNotify &data) const
static uint8 const NotificationType
void Append(WorldPackets::Channel::ChannelNotify &data) const
PlayerNotBannedAppend(std::string const &playerName)
PlayerNotFoundAppend(std::string const &playerName)
void Append(WorldPackets::Channel::ChannelNotify &data) const
static uint8 const NotificationType
static uint8 const NotificationType
PlayerUnbannedAppend(ObjectGuid const &moderator, ObjectGuid const &unbanned)
void Append(WorldPackets::Channel::ChannelNotify &data) const
static uint8 const NotificationType
void Append(WorldPackets::Channel::ChannelNotify &) const
void Append(WorldPackets::Channel::ChannelNotify &data) const
static uint8 const NotificationType
VoiceOffAppend(ObjectGuid const &guid)
static uint8 const NotificationType
void Append(WorldPackets::Channel::ChannelNotify &data) const
VoiceOnAppend(ObjectGuid const &guid)
void Append(WorldPackets::Channel::ChannelNotify &) const
static uint8 const NotificationType
void Append(WorldPackets::Channel::ChannelNotify &) const
static uint8 const NotificationType
void Append(WorldPackets::Channel::ChannelNotify &data) const
Channel const * _channel
static uint8 const NotificationType
YouJoinedAppend(Channel const *channel)
static uint8 const NotificationType
void Append(WorldPackets::Channel::ChannelNotify &data) const
Channel const * _channel
YouLeftAppend(Channel const *channel, bool suspend)