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

Revision 209, 24.3 kB (checked in by yumileroy, 17 years ago)

[svn] Fix some typos.

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