OregonCore  revision 3611e8a-git
Your Favourite TBC server
ChannelHandler.cpp
Go to the documentation of this file.
1 /*
2  * This file is part of the OregonCore 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 "ObjectMgr.h" // for normalizePlayerName
19 #include "ChannelMgr.h"
20 
23 
25 {
26  sLog.outDebug("Opcode %u", recvPacket.GetOpcode());
27 
28  uint32 channel_id;
29  uint8 unknown1, unknown2;
30  std::string channelname, pass;
31 
32  recvPacket >> channel_id >> unknown1 >> unknown2;
33  recvPacket >> channelname;
34 
35  if (channelname.empty())
36  return;
37 
38  recvPacket >> pass;
39  if (ChannelMgr* cMgr = channelMgr(_player->GetTeam()))
40  if (Channel* chn = cMgr->GetJoinChannel(channelname, channel_id))
41  chn->Join(_player->GetGUID(), pass.c_str());
42 }
43 
45 {
46  sLog.outDebug("Opcode %u", recvPacket.GetOpcode());
47 
48  uint32 unk;
49  std::string channelname;
50  recvPacket >> unk; // channel id?
51  recvPacket >> channelname;
52 
53  if (channelname.empty())
54  return;
55 
56  if (ChannelMgr* cMgr = channelMgr(_player->GetTeam()))
57  {
58  if (Channel* chn = cMgr->GetChannel(channelname, _player))
59  chn->Leave(_player->GetGUID(), true);
60  cMgr->LeftChannel(channelname);
61  }
62 }
63 
65 {
66  sLog.outDebug("Opcode %u", recvPacket.GetOpcode());
67 
68  std::string channelname;
69  recvPacket >> channelname;
70 
71  if (ChannelMgr* cMgr = channelMgr(_player->GetTeam()))
72  if (Channel* chn = cMgr->GetChannel(channelname, _player))
73  chn->List(_player);
74 }
75 
77 {
78  sLog.outDebug("Opcode %u", recvPacket.GetOpcode());
79 
80  std::string channelname, pass;
81  recvPacket >> channelname;
82  recvPacket >> pass;
83 
84  if (pass.length() > MAX_CHANNEL_PASS_STR)
85  return;
86 
87  if (ChannelMgr* cMgr = channelMgr(_player->GetTeam()))
88  if (Channel* chn = cMgr->GetChannel(channelname, _player))
89  chn->Password(_player->GetGUID(), pass.c_str());
90 }
91 
93 {
94  sLog.outDebug("Opcode %u", recvPacket.GetOpcode());
95 
96  std::string channelname, newp;
97  recvPacket >> channelname;
98  recvPacket >> newp;
99 
100  if (!normalizePlayerName(newp))
101  return;
102 
103  if (ChannelMgr* cMgr = channelMgr(_player->GetTeam()))
104  if (Channel* chn = cMgr->GetChannel(channelname, _player))
105  chn->SetOwner(_player->GetGUID(), newp.c_str());
106 }
107 
109 {
110  sLog.outDebug("Opcode %u", recvPacket.GetOpcode());
111 
112  std::string channelname;
113  recvPacket >> channelname;
114  if (ChannelMgr* cMgr = channelMgr(_player->GetTeam()))
115  if (Channel* chn = cMgr->GetChannel(channelname, _player))
116  chn->SendWhoOwner(_player->GetGUID());
117 }
118 
120 {
121  sLog.outDebug("Opcode %u", recvPacket.GetOpcode());
122 
123  std::string channelname, otp;
124  recvPacket >> channelname;
125  recvPacket >> otp;
126 
127  if (!normalizePlayerName(otp))
128  return;
129 
130  if (ChannelMgr* cMgr = channelMgr(_player->GetTeam()))
131  if (Channel* chn = cMgr->GetChannel(channelname, _player))
132  chn->SetModerator(_player->GetGUID(), otp.c_str());
133 }
134 
136 {
137  sLog.outDebug("Opcode %u", recvPacket.GetOpcode());
138 
139  std::string channelname, otp;
140  recvPacket >> channelname;
141  recvPacket >> otp;
142 
143  if (!normalizePlayerName(otp))
144  return;
145 
146  if (ChannelMgr* cMgr = channelMgr(_player->GetTeam()))
147  if (Channel* chn = cMgr->GetChannel(channelname, _player))
148  chn->UnsetModerator(_player->GetGUID(), otp.c_str());
149 }
150 
152 {
153  sLog.outDebug("Opcode %u", recvPacket.GetOpcode());
154 
155  std::string channelname, otp;
156  recvPacket >> channelname;
157  recvPacket >> otp;
158 
159  if (!normalizePlayerName(otp))
160  return;
161 
162  if (ChannelMgr* cMgr = channelMgr(_player->GetTeam()))
163  if (Channel* chn = cMgr->GetChannel(channelname, _player))
164  chn->SetMute(_player->GetGUID(), otp.c_str());
165 }
166 
168 {
169  sLog.outDebug("Opcode %u", recvPacket.GetOpcode());
170 
171  std::string channelname, otp;
172  recvPacket >> channelname;
173  recvPacket >> otp;
174 
175  if (!normalizePlayerName(otp))
176  return;
177 
178  if (ChannelMgr* cMgr = channelMgr(_player->GetTeam()))
179  if (Channel* chn = cMgr->GetChannel(channelname, _player))
180  chn->UnsetMute(_player->GetGUID(), otp.c_str());
181 }
182 
184 {
185  sLog.outDebug("Opcode %u", recvPacket.GetOpcode());
186 
187  std::string channelname, otp;
188  recvPacket >> channelname;
189  recvPacket >> otp;
190 
191  if (!normalizePlayerName(otp))
192  return;
193 
194  if (ChannelMgr* cMgr = channelMgr(_player->GetTeam()))
195  if (Channel* chn = cMgr->GetChannel(channelname, _player))
196  chn->Invite(_player->GetGUID(), otp.c_str());
197 }
198 
200 {
201  sLog.outDebug("Opcode %u", recvPacket.GetOpcode());
202 
203  std::string channelname, otp;
204  recvPacket >> channelname;
205  recvPacket >> otp;
206  if (!normalizePlayerName(otp))
207  return;
208 
209  if (ChannelMgr* cMgr = channelMgr(_player->GetTeam()))
210  if (Channel* chn = cMgr->GetChannel(channelname, _player))
211  chn->Kick(_player->GetGUID(), otp.c_str());
212 }
213 
215 {
216  sLog.outDebug("Opcode %u", recvPacket.GetOpcode());
217 
218  std::string channelname, otp;
219  recvPacket >> channelname;
220  recvPacket >> otp;
221 
222  if (!normalizePlayerName(otp))
223  return;
224 
225  if (ChannelMgr* cMgr = channelMgr(_player->GetTeam()))
226  if (Channel* chn = cMgr->GetChannel(channelname, _player))
227  chn->Ban(_player->GetGUID(), otp.c_str());
228 }
229 
231 {
232  sLog.outDebug("Opcode %u", recvPacket.GetOpcode());
233 
234  std::string channelname, otp;
235  recvPacket >> channelname;
236  recvPacket >> otp;
237 
238  if (!normalizePlayerName(otp))
239  return;
240 
241  if (ChannelMgr* cMgr = channelMgr(_player->GetTeam()))
242  if (Channel* chn = cMgr->GetChannel(channelname, _player))
243  chn->UnBan(_player->GetGUID(), otp.c_str());
244 }
245 
247 {
248  sLog.outDebug("Opcode %u", recvPacket.GetOpcode());
249 
250  std::string channelname;
251  recvPacket >> channelname;
252  if (ChannelMgr* cMgr = channelMgr(_player->GetTeam()))
253  if (Channel* chn = cMgr->GetChannel(channelname, _player))
254  chn->Announce(_player->GetGUID());
255 }
256 
258 {
259  sLog.outDebug("Opcode %u", recvPacket.GetOpcode());
260 
261  std::string channelname;
262  recvPacket >> channelname;
263  if (ChannelMgr* cMgr = channelMgr(_player->GetTeam()))
264  if (Channel* chn = cMgr->GetChannel(channelname, _player))
265  chn->Moderate(_player->GetGUID());
266 }
267 
269 {
270  sLog.outDebug("Opcode %u", recvPacket.GetOpcode());
271 
272  std::string channelname;
273  recvPacket >> channelname;
274  if (ChannelMgr* cMgr = channelMgr(_player->GetTeam()))
275  if (Channel* chn = cMgr->GetChannel(channelname, _player))
276  chn->List(_player);
277 }
278 
280 {
281  sLog.outDebug("Opcode %u", recvPacket.GetOpcode());
282 
283  std::string channelname;
284  recvPacket >> channelname;
285  if (ChannelMgr* cMgr = channelMgr(_player->GetTeam()))
286  {
287  if (Channel* chn = cMgr->GetChannel(channelname, _player))
288  {
289  WorldPacket data(SMSG_CHANNEL_MEMBER_COUNT, chn->GetName().size() + 1 + 1 + 4);
290  data << chn->GetName();
291  data << uint8(chn->GetFlags());
292  data << uint32(chn->GetNumPlayers());
293  SendPacket(&data);
294  }
295  }
296 }
297 
299 {
300  sLog.outDebug("Opcode %u", recvPacket.GetOpcode());
301 
302  std::string channelname;
303  recvPacket >> channelname;
304  /*if (ChannelMgr* cMgr = channelMgr(_player->GetTeam()))
305  if (Channel *chn = cMgr->GetChannel(channelname, _player))
306  chn->JoinNotify(_player->GetGUID());*/
307 }
308 
uint16 GetOpcode() const
Definition: WorldPacket.h:44
INSTANTIATE_SINGLETON_1(AllianceChannelMgr)
void HandleChannelSetOwner(WorldPacket &recvPacket)
void HandleChannelOwner(WorldPacket &recvPacket)
void HandleChannelModerator(WorldPacket &recvPacket)
void HandleChannelKick(WorldPacket &recvPacket)
void HandleChannelAnnounce(WorldPacket &recvPacket)
void HandleChannelUnmute(WorldPacket &recvPacket)
#define sLog
Log class singleton.
Definition: Log.h:187
void HandleChannelLeave(WorldPacket &recvPacket)
void HandleChannelMute(WorldPacket &recvPacket)
void HandleChannelModerate(WorldPacket &recvPacket)
void SendPacket(WorldPacket const *packet)
void HandleChannelBan(WorldPacket &recvPacket)
void HandleChannelRosterQuery(WorldPacket &recvPacket)
void HandleChannelUnban(WorldPacket &recvPacket)
bool normalizePlayerName(std::string &name)
Definition: ObjectMgr.cpp:225
void HandleChannelJoin(WorldPacket &recvPacket)
ACE_UINT8 uint8
Definition: Define.h:73
void HandleChannelPassword(WorldPacket &recvPacket)
void HandleChannelInvite(WorldPacket &recvPacket)
void HandleChannelList(WorldPacket &recvPacket)
void HandleChannelUnmoderator(WorldPacket &recvPacket)
#define MAX_CHANNEL_PASS_STR
Definition: ChannelMgr.h:28
void HandleChannelJoinNotify(WorldPacket &recvPacket)
Player * _player
Definition: WorldSession.h:729
uint32 GetTeam() const
Definition: Player.h:2075
ACE_UINT32 uint32
Definition: Define.h:71
ChannelMgr * channelMgr(uint32 team)
Definition: ChannelMgr.h:91
void HandleChannelInfoQuery(WorldPacket &recvPacket)
const uint64 & GetGUID() const
Definition: Object.h:156