TrinityCore
ChannelPackets.cpp
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#include "ChannelPackets.h"
19#include "Channel.h"
20#include "Errors.h"
21
23{
25 _worldPacket.WriteBits(_Channel.length(), 7);
27 _worldPacket << uint32(_Members.size());
29
30 for (ChannelPlayer const& player : _Members)
31 {
32 _worldPacket << player.Guid;
33 _worldPacket << uint32(player.VirtualRealmAddress);
34 _worldPacket << uint8(player.Flags);
35 }
36
37 return &_worldPacket;
38}
39
41{
42 _worldPacket.WriteBits(Type, 6);
43 _worldPacket.WriteBits(_Channel.length(), 7);
44 _worldPacket.WriteBits(Sender.length(), 6);
45
46 _worldPacket << SenderGuid;
47 _worldPacket << SenderAccountID;
48 _worldPacket << uint32(SenderVirtualRealm);
49 _worldPacket << TargetGuid;
50 _worldPacket << uint32(TargetVirtualRealm);
51 _worldPacket << int32(ChatChannelID);
52
54 {
55 _worldPacket << uint8(OldFlags);
56 _worldPacket << uint8(NewFlags);
57 }
58
59 _worldPacket.WriteString(_Channel);
60 _worldPacket.WriteString(Sender);
61
62 return &_worldPacket;
63}
64
66{
67 _worldPacket.WriteBits(_Channel.length(), 7);
68 _worldPacket.WriteBits(ChannelWelcomeMsg.length(), 11);
69 _worldPacket << uint32(_ChannelFlags);
70 _worldPacket << int32(ChatChannelID);
71 _worldPacket << uint64(InstanceID);
72 _worldPacket << ChannelGUID;
73 _worldPacket.WriteString(_Channel);
74 _worldPacket.WriteString(ChannelWelcomeMsg);
75
76 return &_worldPacket;
77}
78
80{
81 _worldPacket.WriteBits(Channel.length(), 7);
82 _worldPacket.WriteBit(Suspended);
83 _worldPacket << int32(ChatChannelID);
84 _worldPacket.WriteString(Channel);
85
86 return &_worldPacket;
87}
88
90{
91 _worldPacket << AddedUserGUID;
92 _worldPacket << uint8(UserFlags);
93 _worldPacket << uint32(_ChannelFlags);
94 _worldPacket << uint32(ChannelID);
95 _worldPacket.WriteBits(ChannelName.length(), 7);
96 _worldPacket.FlushBits();
97 _worldPacket.WriteString(ChannelName);
98 return &_worldPacket;
99}
100
102{
103 _worldPacket << RemovedUserGUID;
104 _worldPacket << uint32(_ChannelFlags);
105 _worldPacket << uint32(ChannelID);
106 _worldPacket.WriteBits(ChannelName.length(), 7);
107 _worldPacket.FlushBits();
108 _worldPacket.WriteString(ChannelName);
109 return &_worldPacket;
110}
111
113{
114 _worldPacket << UpdatedUserGUID;
115 _worldPacket << uint8(UserFlags);
116 _worldPacket << uint32(_ChannelFlags);
117 _worldPacket << uint32(ChannelID);
118 _worldPacket.WriteBits(ChannelName.length(), 7);
119 _worldPacket.FlushBits();
120 _worldPacket.WriteString(ChannelName);
121 return &_worldPacket;
122}
123
125{
126 switch (packet.GetOpcode())
127 {
133 break;
134 default:
135 ABORT();
136 break;
137 }
138}
139
141{
142 ChannelName = _worldPacket.ReadString(_worldPacket.ReadBits(7));
143}
144
146{
147 switch (GetOpcode())
148 {
158 break;
159 default:
160 ABORT();
161 break;
162 }
163}
164
166{
167 uint32 channelNameLength = _worldPacket.ReadBits(7);
168 uint32 nameLength = _worldPacket.ReadBits(9);
169 ChannelName = _worldPacket.ReadString(channelNameLength);
170 Name = _worldPacket.ReadString(nameLength);
171}
172
174{
175 uint32 channelNameLength = _worldPacket.ReadBits(7);
176 uint32 passwordLength = _worldPacket.ReadBits(7);
177 ChannelName = _worldPacket.ReadString(channelNameLength);
178 Password = _worldPacket.ReadString(passwordLength);
179}
180
182{
183 _worldPacket >> ChatChannelId;
184 CreateVoiceSession = _worldPacket.ReadBit();
185 Internal = _worldPacket.ReadBit();
186 uint32 channelLength = _worldPacket.ReadBits(7);
187 uint32 passwordLength = _worldPacket.ReadBits(7);
188 ChannelName = _worldPacket.ReadString(channelLength);
189 Password = _worldPacket.ReadString(passwordLength);
190}
191
193{
194 _worldPacket >> ZoneChannelID;
195 ChannelName = _worldPacket.ReadString(_worldPacket.ReadBits(7));
196}
@ CHAT_MODE_CHANGE_NOTICE
Definition: Channel.h:55
uint8_t uint8
Definition: Define.h:144
int32_t int32
Definition: Define.h:138
uint64_t uint64
Definition: Define.h:141
uint32_t uint32
Definition: Define.h:142
#define ABORT
Definition: Errors.h:74
void WriteString(std::string const &str)
Definition: ByteBuffer.h:500
bool WriteBit(bool bit)
Definition: ByteBuffer.h:175
void WriteBits(std::size_t value, int32 bits)
Definition: ByteBuffer.h:203
std::vector< ChannelPlayer > _Members
WorldPacket const * Write() override
WorldPacket const * Write() override
WorldPacket const * Write() override
WorldPacket const * Write() override
WorldPacket const * Write() override
WorldPacket const * Write() override
WorldPacket const * Write() override
OpcodeClient GetOpcode() const
Definition: Packet.h:68
WorldPacket _worldPacket
Definition: Packet.h:43
@ CMSG_CHAT_CHANNEL_UNBAN
Definition: Opcodes.h:212
@ CMSG_CHAT_CHANNEL_SILENCE_ALL
Definition: Opcodes.h:211
@ CMSG_CHAT_CHANNEL_DISPLAY_LIST
Definition: Opcodes.h:203
@ CMSG_CHAT_CHANNEL_SET_OWNER
Definition: Opcodes.h:210
@ CMSG_CHAT_CHANNEL_MODERATOR
Definition: Opcodes.h:207
@ CMSG_CHAT_CHANNEL_BAN
Definition: Opcodes.h:201
@ CMSG_CHAT_CHANNEL_DECLINE_INVITE
Definition: Opcodes.h:202
@ CMSG_CHAT_CHANNEL_INVITE
Definition: Opcodes.h:204
@ CMSG_CHAT_CHANNEL_UNMODERATOR
Definition: Opcodes.h:213
@ CMSG_CHAT_CHANNEL_KICK
Definition: Opcodes.h:205
@ CMSG_CHAT_CHANNEL_LIST
Definition: Opcodes.h:206
@ CMSG_CHAT_CHANNEL_OWNER
Definition: Opcodes.h:208
@ CMSG_CHAT_CHANNEL_UNSILENCE_ALL
Definition: Opcodes.h:214
@ CMSG_CHAT_CHANNEL_ANNOUNCEMENTS
Definition: Opcodes.h:200
STL namespace.