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

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

[svn] * Proper SVN structure

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