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

Revision 102, 24.1 kB (checked in by yumileroy, 17 years ago)

[svn] Fixed copyright notices to comply with GPL.

Original author: w12x
Date: 2008-10-23 03:29:52-05:00

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