root/trunk/src/game/Channel.cpp @ 42

Revision 39, 24.2 kB (checked in by yumileroy, 17 years ago)

[svn] * Various small changes here and there.
* Implementing MangChat? IRC system.
* Added new config option, MAX_WHO, can be used to set the limit of characters being sent in a /who request from client.

Original author: XTZGZoReX
Date: 2008-10-12 14:03:38-05:00

Line 
1/*
2 * Copyright (C) 2005-2008 MaNGOS <http://www.mangosproject.org/>
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
17 */
18
19#include "Channel.h"
20#include "ObjectMgr.h"
21#include "World.h"
22#include "SocialMgr.h"
23#include "IRCClient.h"
24
25Channel::Channel(std::string name, uint32 channel_id)
26: m_name(name), m_announce(true), m_moderate(false), m_channelId(channel_id), m_ownerGUID(0), m_password(""), m_flags(0)
27{
28    // set special flags if built-in channel
29    ChatChannelsEntry const* ch = GetChannelEntryFor(channel_id);
30    if(ch)                                                  // it's built-in channel
31    {
32        channel_id = ch->ChannelID;                         // built-in channel
33        m_announce = false;                                 // no join/leave announces
34
35        m_flags |= CHANNEL_FLAG_GENERAL;                    // for all built-in channels
36
37        if(ch->flags & CHANNEL_DBC_FLAG_TRADE)              // for trade channel
38            m_flags |= CHANNEL_FLAG_TRADE;
39
40        if(ch->flags & CHANNEL_DBC_FLAG_CITY_ONLY2)         // for city only channels
41            m_flags |= CHANNEL_FLAG_CITY;
42
43        if(ch->flags & CHANNEL_DBC_FLAG_LFG)                // for LFG channel
44            m_flags |= CHANNEL_FLAG_LFG;
45        else                                                // for all other channels
46            m_flags |= CHANNEL_FLAG_NOT_LFG;
47    }
48    else                                                    // it's custom channel
49    {
50        m_flags |= CHANNEL_FLAG_CUSTOM;
51    }
52}
53
54void Channel::Join(uint64 p, const char *pass)
55{
56    WorldPacket data;
57    if(IsOn(p))
58    {
59        if(!IsConstant())                                   // non send error message for built-in channels
60        {
61            MakePlayerAlreadyMember(&data, p);
62            SendToOne(&data, p);
63        }
64        return;
65    }
66
67    if(IsBanned(p))
68    {
69        MakeBanned(&data);
70        SendToOne(&data, p);
71        return;
72    }
73
74    if(m_password.length() > 0 && strcmp(pass, m_password.c_str()))
75    {
76        MakeWrongPassword(&data);
77        SendToOne(&data, p);
78        return;
79    }
80
81    Player *plr = objmgr.GetPlayer(p);
82
83    if(plr)
84    {
85        if(HasFlag(CHANNEL_FLAG_LFG) &&
86            sWorld.getConfig(CONFIG_RESTRICTED_LFG_CHANNEL) && plr->GetSession()->GetSecurity() == SEC_PLAYER &&
87            (plr->GetGroup() || plr->m_lookingForGroup.Empty()) )
88        {
89            MakeNotInLfg(&data);
90            SendToOne(&data, p);
91            return;
92        }
93
94        if(plr->GetGuildId() && (GetFlags() == 0x38))
95            return;
96
97        plr->JoinedChannel(this);
98    }
99
100    if(m_announce && (!plr || plr->GetSession()->GetSecurity() < SEC_GAMEMASTER || !sWorld.getConfig(CONFIG_SILENTLY_GM_JOIN_TO_CHANNEL) ))
101    {
102        MakeJoined(&data, p);
103        SendToAll(&data);
104    }
105
106    data.clear();
107
108    PlayerInfo pinfo;
109    pinfo.player = p;
110    pinfo.flags = 0;
111    players[p] = pinfo;
112
113    MakeYouJoined(&data);
114    SendToOne(&data, p);
115
116    sIRC.Handle_WoW_Channel(m_name, objmgr.GetPlayer(p), CHANNEL_JOIN);
117
118    JoinNotify(p);
119}
120
121void Channel::Leave(uint64 p, bool send)
122{
123    if(!IsOn(p))
124    {
125        if(send)
126        {
127            WorldPacket data;
128            MakeNotMember(&data);
129            SendToOne(&data, p);
130        }
131    }
132    else
133    {
134        Player *plr = objmgr.GetPlayer(p);
135
136        if(send)
137        {
138            WorldPacket data;
139            MakeYouLeft(&data);
140            SendToOne(&data, p);
141            if(plr)
142                plr->LeftChannel(this);
143            data.clear();
144        }
145
146        bool changeowner = players[p].IsOwner();
147
148        players.erase(p);
149        if(m_announce && (!plr || plr->GetSession()->GetSecurity() < SEC_GAMEMASTER || !sWorld.getConfig(CONFIG_SILENTLY_GM_JOIN_TO_CHANNEL) ))
150        {
151            WorldPacket data;
152            MakeLeft(&data, p);
153            SendToAll(&data);
154        }
155
156        LeaveNotify(p);
157
158        sIRC.Handle_WoW_Channel(m_name, objmgr.GetPlayer(p), CHANNEL_LEAVE);
159
160        if(changeowner)
161        {
162            uint64 newowner = !players.empty() ? players.begin()->second.player : 0;
163            SetOwner(newowner);
164        }
165    }
166}
167
168void Channel::KickOrBan(uint64 good, const char *badname, bool ban)
169{
170    uint32 sec = 0;
171    Player *gplr = objmgr.GetPlayer(good);
172    if(gplr)
173        sec = gplr->GetSession()->GetSecurity();
174
175    if(!IsOn(good))
176    {
177        WorldPacket data;
178        MakeNotMember(&data);
179        SendToOne(&data, good);
180    }
181    else if(!players[good].IsModerator() && sec < SEC_GAMEMASTER)
182    {
183        WorldPacket data;
184        MakeNotModerator(&data);
185        SendToOne(&data, good);
186    }
187    else
188    {
189        Player *bad = objmgr.GetPlayer(badname);
190        if(bad == NULL || !IsOn(bad->GetGUID()))
191        {
192            WorldPacket data;
193            MakePlayerNotFound(&data, badname);
194            SendToOne(&data, good);
195        }
196        else if(sec < SEC_GAMEMASTER && bad->GetGUID() == m_ownerGUID && good != m_ownerGUID)
197        {
198            WorldPacket data;
199            MakeNotOwner(&data);
200            SendToOne(&data, good);
201        }
202        else
203        {
204            bool changeowner = (m_ownerGUID == bad->GetGUID());
205
206            WorldPacket data;
207
208            if(ban && !IsBanned(bad->GetGUID()))
209            {
210                banned.push_back(bad->GetGUID());
211                MakePlayerBanned(&data, bad->GetGUID(), good);
212            }
213            else
214                MakePlayerKicked(&data, bad->GetGUID(), good);
215
216            SendToAll(&data);
217            players.erase(bad->GetGUID());
218            bad->LeftChannel(this);
219
220            if(changeowner)
221            {
222                uint64 newowner = !players.empty() ? good : false;
223                SetOwner(newowner);
224            }
225        }
226    }
227}
228
229void Channel::UnBan(uint64 good, const char *badname)
230{
231    uint32 sec = 0;
232    Player *gplr = objmgr.GetPlayer(good);
233    if(gplr)
234        sec = gplr->GetSession()->GetSecurity();
235
236    if(!IsOn(good))
237    {
238        WorldPacket data;
239        MakeNotMember(&data);
240        SendToOne(&data, good);
241    }
242    else if(!players[good].IsModerator() && sec < SEC_GAMEMASTER)
243    {
244        WorldPacket data;
245        MakeNotModerator(&data);
246        SendToOne(&data, good);
247    }
248    else
249    {
250        Player *bad = objmgr.GetPlayer(badname);
251        if(bad == NULL || !IsBanned(bad->GetGUID()))
252        {
253            WorldPacket data;
254            MakePlayerNotFound(&data, badname);
255            SendToOne(&data, good);
256        }
257        else
258        {
259            banned.remove(bad->GetGUID());
260
261            WorldPacket data;
262            MakePlayerUnbanned(&data, bad->GetGUID(), good);
263            SendToAll(&data);
264        }
265    }
266}
267
268void Channel::Password(uint64 p, const char *pass)
269{
270    uint32 sec = 0;
271    Player *plr = objmgr.GetPlayer(p);
272    if(plr)
273        sec = plr->GetSession()->GetSecurity();
274
275    if(!IsOn(p))
276    {
277        WorldPacket data;
278        MakeNotMember(&data);
279        SendToOne(&data, p);
280    }
281    else if(!players[p].IsModerator() && sec < SEC_GAMEMASTER)
282    {
283        WorldPacket data;
284        MakeNotModerator(&data);
285        SendToOne(&data, p);
286    }
287    else
288    {
289        m_password = pass;
290
291        WorldPacket data;
292        MakePasswordChanged(&data, p);
293        SendToAll(&data);
294    }
295}
296
297void Channel::SetMode(uint64 p, const char *p2n, bool mod, bool set)
298{
299    uint32 sec = 0;
300    Player *plr = objmgr.GetPlayer(p);
301    if(plr)
302        sec = plr->GetSession()->GetSecurity();
303
304    if(!IsOn(p))
305    {
306        WorldPacket data;
307        MakeNotMember(&data);
308        SendToOne(&data, p);
309    }
310    else if(!players[p].IsModerator() && sec < SEC_GAMEMASTER)
311    {
312        WorldPacket data;
313        MakeNotModerator(&data);
314        SendToOne(&data, p);
315    }
316    else
317    {
318        Player *newp = objmgr.GetPlayer(p2n);
319        if(!newp)
320        {
321            WorldPacket data;
322            MakePlayerNotFound(&data, p2n);
323            SendToOne(&data, p);
324            return;
325        }
326
327        PlayerInfo inf = players[newp->GetGUID()];
328        if(p == m_ownerGUID && newp->GetGUID() == m_ownerGUID && mod)
329            return;
330
331        if(!IsOn(newp->GetGUID()))
332        {
333            WorldPacket data;
334            MakePlayerNotFound(&data, p2n);
335            SendToOne(&data, p);
336            return;
337        }
338
339        // allow make moderator from another team only if both is GMs
340        // at this moment this only way to show channel post for GM from another team
341        if( (plr->GetSession()->GetSecurity() < SEC_GAMEMASTER || newp->GetSession()->GetSecurity() < SEC_GAMEMASTER) &&
342            plr->GetTeam() != newp->GetTeam() && !sWorld.getConfig(CONFIG_ALLOW_TWO_SIDE_INTERACTION_CHANNEL) )
343        {
344            WorldPacket data;
345            MakePlayerNotFound(&data, p2n);
346            SendToOne(&data, p);
347            return;
348        }
349
350        if(m_ownerGUID == newp->GetGUID() && m_ownerGUID != p)
351        {
352            WorldPacket data;
353            MakeNotOwner(&data);
354            SendToOne(&data, p);
355            return;
356        }
357
358        if(mod)
359            SetModerator(newp->GetGUID(), set);
360        else
361            SetMute(newp->GetGUID(), set);
362    }
363}
364
365void Channel::SetOwner(uint64 p, const char *newname)
366{
367    uint32 sec = 0;
368    Player *plr = objmgr.GetPlayer(p);
369    if(plr)
370        sec = plr->GetSession()->GetSecurity();
371
372    if(!IsOn(p))
373    {
374        WorldPacket data;
375        MakeNotMember(&data);
376        SendToOne(&data, p);
377        return;
378    }
379
380    if(sec < SEC_GAMEMASTER && p != m_ownerGUID)
381    {
382        WorldPacket data;
383        MakeNotOwner(&data);
384        SendToOne(&data, p);
385        return;
386    }
387
388    Player *newp = objmgr.GetPlayer(newname);
389    if(newp == NULL || !IsOn(newp->GetGUID()))
390    {
391        WorldPacket data;
392        MakePlayerNotFound(&data, newname);
393        SendToOne(&data, p);
394        return;
395    }
396
397    if(newp->GetTeam() != plr->GetTeam() && !sWorld.getConfig(CONFIG_ALLOW_TWO_SIDE_INTERACTION_CHANNEL))
398    {
399        WorldPacket data;
400        MakePlayerNotFound(&data, newname);
401        SendToOne(&data, p);
402        return;
403    }
404
405    players[newp->GetGUID()].SetModerator(true);
406    SetOwner(newp->GetGUID());
407}
408
409void Channel::SendWhoOwner(uint64 p)
410{
411    if(!IsOn(p))
412    {
413        WorldPacket data;
414        MakeNotMember(&data);
415        SendToOne(&data, p);
416    }
417    else
418    {
419        WorldPacket data;
420        MakeChannelOwner(&data);
421        SendToOne(&data, p);
422    }
423}
424
425void Channel::List(Player* player)
426{
427    uint64 p = player->GetGUID();
428
429    if(!IsOn(p))
430    {
431        WorldPacket data;
432        MakeNotMember(&data);
433        SendToOne(&data, p);
434    }
435    else
436    {
437        WorldPacket data(SMSG_CHANNEL_LIST, 1+(GetName().size()+1)+1+4+players.size()*(8+1));
438        data << uint8(1);                                   // channel type?
439        data << GetName();                                  // channel name
440        data << uint8(GetFlags());                          // channel flags?
441
442        size_t pos = data.wpos();
443        data << uint32(0);                                  // size of list, placeholder
444
445        bool gmInWhoList = sWorld.getConfig(CONFIG_GM_IN_WHO_LIST) || player->GetSession()->GetSecurity() > SEC_PLAYER;
446
447        uint32 count  = 0;
448        for(PlayerList::iterator i = players.begin(); i != players.end(); ++i)
449        {
450            Player *plr = objmgr.GetPlayer(i->first);
451
452            // PLAYER can't see MODERATOR, GAME MASTER, ADMINISTRATOR characters
453            // MODERATOR, GAME MASTER, ADMINISTRATOR can see all
454            if( plr && ( plr->GetSession()->GetSecurity() == SEC_PLAYER || gmInWhoList && plr->IsVisibleGloballyFor(player) ) )
455            {
456                data << uint64(i->first);
457                data << uint8(i->second.flags);             // flags seems to be changed...
458                ++count;
459            }
460        }
461
462        data.put<uint32>(pos,count);
463
464        SendToOne(&data, p);
465    }
466}
467
468void Channel::Announce(uint64 p)
469{
470    uint32 sec = 0;
471    Player *plr = objmgr.GetPlayer(p);
472    if(plr)
473        sec = plr->GetSession()->GetSecurity();
474
475    if(!IsOn(p))
476    {
477        WorldPacket data;
478        MakeNotMember(&data);
479        SendToOne(&data, p);
480    }
481    else if(!players[p].IsModerator() && sec < SEC_GAMEMASTER)
482    {
483        WorldPacket data;
484        MakeNotModerator(&data);
485        SendToOne(&data, p);
486    }
487    else
488    {
489        m_announce = !m_announce;
490
491        WorldPacket data;
492        if(m_announce)
493            MakeAnnouncementsOn(&data, p);
494        else
495            MakeAnnouncementsOff(&data, p);
496        SendToAll(&data);
497    }
498}
499
500void Channel::Moderate(uint64 p)
501{
502    uint32 sec = 0;
503    Player *plr = objmgr.GetPlayer(p);
504    if(plr)
505        sec = plr->GetSession()->GetSecurity();
506
507    if(!IsOn(p))
508    {
509        WorldPacket data;
510        MakeNotMember(&data);
511        SendToOne(&data, p);
512    }
513    else if(!players[p].IsModerator() && sec < SEC_GAMEMASTER)
514    {
515        WorldPacket data;
516        MakeNotModerator(&data);
517        SendToOne(&data, p);
518    }
519    else
520    {
521        m_moderate = !m_moderate;
522
523        WorldPacket data;
524        if(m_moderate)
525            MakeModerationOn(&data, p);
526        else
527            MakeModerationOff(&data, p);
528        SendToAll(&data);
529    }
530}
531
532void Channel::Say(uint64 p, const char *what, uint32 lang)
533{
534    if(!what)
535        return;
536    if (sWorld.getConfig(CONFIG_ALLOW_TWO_SIDE_INTERACTION_CHANNEL))
537        lang = LANG_UNIVERSAL;
538
539    uint32 sec = 0;
540    Player *plr = objmgr.GetPlayer(p);
541    if(plr)
542        sec = plr->GetSession()->GetSecurity();
543
544    if(!IsOn(p))
545    {
546        WorldPacket data;
547        MakeNotMember(&data);
548        SendToOne(&data, p);
549    }
550    else if(players[p].IsMuted())
551    {
552        WorldPacket data;
553        MakeMuted(&data);
554        SendToOne(&data, p);
555    }
556    else if(m_moderate && !players[p].IsModerator() && sec < SEC_GAMEMASTER)
557    {
558        WorldPacket data;
559        MakeNotModerator(&data);
560        SendToOne(&data, p);
561    }
562    else
563    {
564        uint32 messageLength = strlen(what) + 1;
565
566        WorldPacket data(SMSG_MESSAGECHAT, 1+4+8+4+m_name.size()+1+8+4+messageLength+1);
567        data << (uint8)CHAT_MSG_CHANNEL;
568        data << (uint32)lang;
569        data << p;                                          // 2.1.0
570        data << uint32(0);                                  // 2.1.0
571        data << m_name;
572        data << p;
573        data << messageLength;
574        data << what;
575        data << uint8(plr ? plr->chatTag() : 0);
576
577        SendToAll(&data, !players[p].IsModerator() ? p : false);
578    }
579}
580
581void Channel::Invite(uint64 p, const char *newname)
582{
583    if(!IsOn(p))
584    {
585        WorldPacket data;
586        MakeNotMember(&data);
587        SendToOne(&data, p);
588        return;
589    }
590
591    Player *newp = objmgr.GetPlayer(newname);
592    if(!newp)
593    {
594        WorldPacket data;
595        MakePlayerNotFound(&data, newname);
596        SendToOne(&data, p);
597        return;
598    }
599
600    Player *plr = objmgr.GetPlayer(p);
601    if (!plr)
602        return;
603
604    if (newp->GetTeam() != plr->GetTeam() && !sWorld.getConfig(CONFIG_ALLOW_TWO_SIDE_INTERACTION_CHANNEL))
605    {
606        WorldPacket data;
607        MakeInviteWrongFaction(&data);
608        SendToOne(&data, p);
609        return;
610    }
611
612    if(IsOn(newp->GetGUID()))
613    {
614        WorldPacket data;
615        MakePlayerAlreadyMember(&data, newp->GetGUID());
616        SendToOne(&data, p);
617        return;
618    }
619
620    WorldPacket data;
621    if(!newp->GetSocial()->HasIgnore(GUID_LOPART(p)))
622    {
623        MakeInvite(&data, p);
624        SendToOne(&data, newp->GetGUID());
625        data.clear();
626    }
627    MakePlayerInvited(&data, newp->GetGUID());
628    SendToOne(&data, p);
629}
630
631void Channel::SetOwner(uint64 guid, bool exclaim)
632{
633    if(m_ownerGUID)
634    {
635        // [] will re-add player after it possible removed
636        PlayerList::iterator p_itr = players.find(m_ownerGUID);
637        if(p_itr != players.end())
638            p_itr->second.SetOwner(false);
639    }
640
641    m_ownerGUID = guid;
642    if(m_ownerGUID)
643    {
644        uint8 oldFlag = GetPlayerFlags(m_ownerGUID);
645        players[m_ownerGUID].SetOwner(true);
646
647        WorldPacket data;
648        MakeModeChange(&data, m_ownerGUID, oldFlag);
649        SendToAll(&data);
650
651        if(exclaim)
652        {
653            MakeOwnerChanged(&data, m_ownerGUID);
654            SendToAll(&data);
655        }
656    }
657}
658
659void Channel::SendToAll(WorldPacket *data, uint64 p)
660{
661    for(PlayerList::iterator i = players.begin(); i != players.end(); ++i)
662    {
663        Player *plr = objmgr.GetPlayer(i->first);
664        if(plr)
665        {
666            if(!p || !plr->GetSocial()->HasIgnore(GUID_LOPART(p)))
667                plr->GetSession()->SendPacket(data);
668        }
669    }
670}
671
672void Channel::SendToAllButOne(WorldPacket *data, uint64 who)
673{
674    for(PlayerList::iterator i = players.begin(); i != players.end(); ++i)
675    {
676        if(i->first != who)
677        {
678            Player *plr = objmgr.GetPlayer(i->first);
679            if(plr)
680                plr->GetSession()->SendPacket(data);
681        }
682    }
683}
684
685void Channel::SendToOne(WorldPacket *data, uint64 who)
686{
687    Player *plr = objmgr.GetPlayer(who);
688    if(plr)
689        plr->GetSession()->SendPacket(data);
690}
691
692void Channel::Voice(uint64 guid1, uint64 guid2)
693{
694
695}
696
697void Channel::DeVoice(uint64 guid1, uint64 guid2)
698{
699
700}
701
702// done
703void Channel::MakeNotifyPacket(WorldPacket *data, uint8 notify_type)
704{
705    data->Initialize(SMSG_CHANNEL_NOTIFY, 1+m_name.size()+1);
706    *data << uint8(notify_type);
707    *data << m_name;
708}
709
710// done 0x00
711void Channel::MakeJoined(WorldPacket *data, uint64 guid)
712{
713    MakeNotifyPacket(data, CHAT_JOINED_NOTICE);
714    *data << uint64(guid);
715}
716
717// done 0x01
718void Channel::MakeLeft(WorldPacket *data, uint64 guid)
719{
720    MakeNotifyPacket(data, CHAT_LEFT_NOTICE);
721    *data << uint64(guid);
722}
723
724// done 0x02
725void Channel::MakeYouJoined(WorldPacket *data)
726{
727    MakeNotifyPacket(data, CHAT_YOU_JOINED_NOTICE);
728    *data << uint8(GetFlags());
729    *data << uint32(GetChannelId());
730    *data << uint32(0);
731}
732
733// done 0x03
734void Channel::MakeYouLeft(WorldPacket *data)
735{
736    MakeNotifyPacket(data, CHAT_YOU_LEFT_NOTICE);
737    *data << uint32(GetChannelId());
738    *data << uint8(0);                                      // can be 0x00 and 0x01
739}
740
741// done 0x04
742void Channel::MakeWrongPassword(WorldPacket *data)
743{
744    MakeNotifyPacket(data, CHAT_WRONG_PASSWORD_NOTICE);
745}
746
747// done 0x05
748void Channel::MakeNotMember(WorldPacket *data)
749{
750    MakeNotifyPacket(data, CHAT_NOT_MEMBER_NOTICE);
751}
752
753// done 0x06
754void Channel::MakeNotModerator(WorldPacket *data)
755{
756    MakeNotifyPacket(data, CHAT_NOT_MODERATOR_NOTICE);
757}
758
759// done 0x07
760void Channel::MakePasswordChanged(WorldPacket *data, uint64 guid)
761{
762    MakeNotifyPacket(data, CHAT_PASSWORD_CHANGED_NOTICE);
763    *data << uint64(guid);
764}
765
766// done 0x08
767void Channel::MakeOwnerChanged(WorldPacket *data, uint64 guid)
768{
769    MakeNotifyPacket(data, CHAT_OWNER_CHANGED_NOTICE);
770    *data << uint64(guid);
771}
772
773// done 0x09
774void Channel::MakePlayerNotFound(WorldPacket *data, std::string name)
775{
776    MakeNotifyPacket(data, CHAT_PLAYER_NOT_FOUND_NOTICE);
777    *data << name;
778}
779
780// done 0x0A
781void Channel::MakeNotOwner(WorldPacket *data)
782{
783    MakeNotifyPacket(data, CHAT_NOT_OWNER_NOTICE);
784}
785
786// done 0x0B
787void Channel::MakeChannelOwner(WorldPacket *data)
788{
789    std::string name = "";
790
791    if(!objmgr.GetPlayerNameByGUID(m_ownerGUID, name) || name.empty())
792        name = "PLAYER_NOT_FOUND";
793
794    MakeNotifyPacket(data, CHAT_CHANNEL_OWNER_NOTICE);
795    *data << ((IsConstant() || !m_ownerGUID) ? "Nobody" : name);
796}
797
798// done 0x0C
799void Channel::MakeModeChange(WorldPacket *data, uint64 guid, uint8 oldflags)
800{
801    MakeNotifyPacket(data, CHAT_MODE_CHANGE_NOTICE);
802    *data << uint64(guid);
803    *data << uint8(oldflags);
804    *data << uint8(GetPlayerFlags(guid));
805}
806
807// done 0x0D
808void Channel::MakeAnnouncementsOn(WorldPacket *data, uint64 guid)
809{
810    MakeNotifyPacket(data, CHAT_ANNOUNCEMENTS_ON_NOTICE);
811    *data << uint64(guid);
812}
813
814// done 0x0E
815void Channel::MakeAnnouncementsOff(WorldPacket *data, uint64 guid)
816{
817    MakeNotifyPacket(data, CHAT_ANNOUNCEMENTS_OFF_NOTICE);
818    *data << uint64(guid);
819}
820
821// done 0x0F
822void Channel::MakeModerationOn(WorldPacket *data, uint64 guid)
823{
824    MakeNotifyPacket(data, CHAT_MODERATION_ON_NOTICE);
825    *data << uint64(guid);
826}
827
828// done 0x10
829void Channel::MakeModerationOff(WorldPacket *data, uint64 guid)
830{
831    MakeNotifyPacket(data, CHAT_MODERATION_OFF_NOTICE);
832    *data << uint64(guid);
833}
834
835// done 0x11
836void Channel::MakeMuted(WorldPacket *data)
837{
838    MakeNotifyPacket(data, CHAT_MUTED_NOTICE);
839}
840
841// done 0x12
842void Channel::MakePlayerKicked(WorldPacket *data, uint64 bad, uint64 good)
843{
844    MakeNotifyPacket(data, CHAT_PLAYER_KICKED_NOTICE);
845    *data << uint64(bad);
846    *data << uint64(good);
847}
848
849// done 0x13
850void Channel::MakeBanned(WorldPacket *data)
851{
852    MakeNotifyPacket(data, CHAT_BANNED_NOTICE);
853}
854
855// done 0x14
856void Channel::MakePlayerBanned(WorldPacket *data, uint64 bad, uint64 good)
857{
858    MakeNotifyPacket(data, CHAT_PLAYER_BANNED_NOTICE);
859    *data << uint64(bad);
860    *data << uint64(good);
861}
862
863// done 0x15
864void Channel::MakePlayerUnbanned(WorldPacket *data, uint64 bad, uint64 good)
865{
866    MakeNotifyPacket(data, CHAT_PLAYER_UNBANNED_NOTICE);
867    *data << uint64(bad);
868    *data << uint64(good);
869}
870
871// done 0x16
872void Channel::MakePlayerNotBanned(WorldPacket *data, uint64 guid)
873{
874    MakeNotifyPacket(data, CHAT_PLAYER_NOT_BANNED_NOTICE);
875    *data << uint64(guid);
876}
877
878// done 0x17
879void Channel::MakePlayerAlreadyMember(WorldPacket *data, uint64 guid)
880{
881    MakeNotifyPacket(data, CHAT_PLAYER_ALREADY_MEMBER_NOTICE);
882    *data << uint64(guid);
883}
884
885// done 0x18
886void Channel::MakeInvite(WorldPacket *data, uint64 guid)
887{
888    MakeNotifyPacket(data, CHAT_INVITE_NOTICE);
889    *data << uint64(guid);
890}
891
892// done 0x19
893void Channel::MakeInviteWrongFaction(WorldPacket *data)
894{
895    MakeNotifyPacket(data, CHAT_INVITE_WRONG_FACTION_NOTICE);
896}
897
898// done 0x1A
899void Channel::MakeWrongFaction(WorldPacket *data)
900{
901    MakeNotifyPacket(data, CHAT_WRONG_FACTION_NOTICE);
902}
903
904// done 0x1B
905void Channel::MakeInvalidName(WorldPacket *data)
906{
907    MakeNotifyPacket(data, CHAT_INVALID_NAME_NOTICE);
908}
909
910// done 0x1C
911void Channel::MakeNotModerated(WorldPacket *data)
912{
913    MakeNotifyPacket(data, CHAT_NOT_MODERATED_NOTICE);
914}
915
916// done 0x1D
917void Channel::MakePlayerInvited(WorldPacket *data, uint64 guid)
918{
919    std::string name;
920
921    if(!objmgr.GetPlayerNameByGUID(guid, name) || name.empty())
922        return;                                             // player name not found
923
924    MakeNotifyPacket(data, CHAT_PLAYER_INVITED_NOTICE);
925    *data << name;
926}
927
928// done 0x1E
929void Channel::MakePlayerInviteBanned(WorldPacket *data, uint64 guid)
930{
931    MakeNotifyPacket(data, CHAT_PLAYER_INVITE_BANNED_NOTICE);
932    *data << uint64(guid);
933}
934
935// done 0x1F
936void Channel::MakeThrottled(WorldPacket *data)
937{
938    MakeNotifyPacket(data, CHAT_THROTTLED_NOTICE);
939}
940
941// done 0x20
942void Channel::MakeNotInArea(WorldPacket *data)
943{
944    MakeNotifyPacket(data, CHAT_NOT_IN_AREA_NOTICE);
945}
946
947// done 0x21
948void Channel::MakeNotInLfg(WorldPacket *data)
949{
950    MakeNotifyPacket(data, CHAT_NOT_IN_LFG_NOTICE);
951}
952
953// done 0x22
954void Channel::MakeVoiceOn(WorldPacket *data, uint64 guid)
955{
956    MakeNotifyPacket(data, CHAT_VOICE_ON_NOTICE);
957    *data << uint64(guid);
958}
959
960// done 0x23
961void Channel::MakeVoiceOff(WorldPacket *data, uint64 guid)
962{
963    MakeNotifyPacket(data, CHAT_VOICE_OFF_NOTICE);
964    *data << uint64(guid);
965}
966
967void Channel::JoinNotify(uint64 guid)
968{
969    WorldPacket data;
970
971    if(IsConstant())
972        data.Initialize(SMSG_USERLIST_ADD, 8+1+1+4+GetName().size()+1);
973    else
974        data.Initialize(SMSG_USERLIST_UPDATE, 8+1+1+4+GetName().size()+1);
975
976    data << uint64(guid);
977    data << uint8(GetPlayerFlags(guid));
978    data << uint8(GetFlags());
979    data << uint32(GetNumPlayers());
980    data << GetName();
981    SendToAll(&data);
982}
983
984void Channel::LeaveNotify(uint64 guid)
985{
986    WorldPacket data(SMSG_USERLIST_REMOVE, 8+1+4+GetName().size()+1);
987    data << uint64(guid);
988    data << uint8(GetFlags());
989    data << uint32(GetNumPlayers());
990    data << GetName();
991    SendToAll(&data);
992}
Note: See TracBrowser for help on using the browser.