AzerothCore 3.3.5a
OpenSource WoW Emulator
Loading...
Searching...
No Matches
Channel Class Reference

#include "Channel.h"

Classes

struct  PlayerInfo
 

Public Member Functions

 Channel (std::string const &name, uint32 channel_id, uint32 channelDBId, TeamId teamId=TEAM_NEUTRAL, bool announce=true, bool ownership=true)
 
std::string const & GetName () const
 
uint32 GetChannelId () const
 
uint32 GetChannelDBId () const
 
bool IsConstant () const
 
bool IsAnnounce () const
 
bool IsLFG () const
 
std::string const & GetPassword () const
 
void SetPassword (std::string const &npassword)
 
uint32 GetNumPlayers () const
 
uint8 GetFlags () const
 
bool HasFlag (uint8 flag) const
 
void JoinChannel (Player *player, std::string const &pass)
 
void LeaveChannel (Player *player, bool send=true)
 
void KickOrBan (Player const *player, std::string const &badname, bool ban)
 
void Kick (Player const *player, std::string const &badname)
 
void Ban (Player const *player, std::string const &badname)
 
void AddBan (ObjectGuid guid, uint32 time)
 
void UnBan (Player const *player, std::string const &badname)
 
void UnBan (ObjectGuid guid)
 
void Password (Player const *player, std::string const &pass)
 
void SetMode (Player const *player, std::string const &p2n, bool mod, bool set)
 
void SetOwner (ObjectGuid guid, bool exclaim=true)
 
void SetOwner (Player const *player, std::string const &name)
 
void SendWhoOwner (ObjectGuid guid)
 
void SetModerator (Player const *player, std::string const &newname)
 
void UnsetModerator (Player const *player, std::string const &newname)
 
void SetMute (Player const *player, std::string const &newname)
 
void UnsetMute (Player const *player, std::string const &newname)
 
void List (Player const *player)
 
void Announce (Player const *player)
 
void Say (ObjectGuid guid, std::string const &what, uint32 lang)
 
void Invite (Player const *player, std::string const &newp)
 
void Voice (ObjectGuid guid1, ObjectGuid guid2)
 
void DeVoice (ObjectGuid guid1, ObjectGuid guid2)
 
void JoinNotify (Player *p)
 
void LeaveNotify (Player *p)
 
void FlagsNotify (Player *p)
 
void ToggleModeration (Player *p)
 
void AddWatching (Player *p)
 
void RemoveWatching (Player *p)
 

Static Public Member Functions

static void CleanOldChannelsInDB ()
 

Private Types

typedef std::unordered_map< ObjectGuid, PlayerInfoPlayerContainer
 
typedef std::unordered_map< ObjectGuid, uint32BannedContainer
 
typedef std::unordered_set< Player * > PlayersWatchingContainer
 

Private Member Functions

void MakeNotifyPacket (WorldPacket *data, uint8 notify_type)
 
void MakeJoined (WorldPacket *data, ObjectGuid guid)
 
void MakeLeft (WorldPacket *data, ObjectGuid guid)
 
void MakeYouJoined (WorldPacket *data)
 
void MakeYouLeft (WorldPacket *data)
 
void MakeWrongPassword (WorldPacket *data)
 
void MakeNotMember (WorldPacket *data)
 
void MakeNotModerator (WorldPacket *data)
 
void MakePasswordChanged (WorldPacket *data, ObjectGuid guid)
 
void MakeOwnerChanged (WorldPacket *data, ObjectGuid guid)
 
void MakePlayerNotFound (WorldPacket *data, std::string const &name)
 
void MakeNotOwner (WorldPacket *data)
 
void MakeChannelOwner (WorldPacket *data)
 
void MakeModeChange (WorldPacket *data, ObjectGuid guid, uint8 oldflags)
 
void MakeAnnouncementsOn (WorldPacket *data, ObjectGuid guid)
 
void MakeAnnouncementsOff (WorldPacket *data, ObjectGuid guid)
 
void MakeMuted (WorldPacket *data)
 
void MakePlayerKicked (WorldPacket *data, ObjectGuid bad, ObjectGuid good)
 
void MakeBanned (WorldPacket *data)
 
void MakePlayerBanned (WorldPacket *data, ObjectGuid bad, ObjectGuid good)
 
void MakePlayerUnbanned (WorldPacket *data, ObjectGuid bad, ObjectGuid good)
 
void MakePlayerNotBanned (WorldPacket *data, std::string const &name)
 
void MakePlayerAlreadyMember (WorldPacket *data, ObjectGuid guid)
 
void MakeInvite (WorldPacket *data, ObjectGuid guid)
 
void MakeInviteWrongFaction (WorldPacket *data)
 
void MakeWrongFaction (WorldPacket *data)
 
void MakeInvalidName (WorldPacket *data)
 
void MakeNotModerated (WorldPacket *data)
 
void MakePlayerInvited (WorldPacket *data, std::string const &name)
 
void MakePlayerInviteBanned (WorldPacket *data, std::string const &name)
 
void MakeThrottled (WorldPacket *data)
 
void MakeNotInArea (WorldPacket *data)
 
void MakeNotInLfg (WorldPacket *data)
 
void MakeVoiceOn (WorldPacket *data, ObjectGuid guid)
 
void MakeVoiceOff (WorldPacket *data, ObjectGuid guid)
 
void MakeModerationOn (WorldPacket *data, ObjectGuid guid)
 
void MakeModerationOff (WorldPacket *data, ObjectGuid guid)
 
void SendToAll (WorldPacket *data, ObjectGuid guid=ObjectGuid::Empty)
 
void SendToAllButOne (WorldPacket *data, ObjectGuid who)
 
void SendToOne (WorldPacket *data, ObjectGuid who)
 
void SendToAllWatching (WorldPacket *data)
 
bool ShouldAnnouncePlayer (Player const *player) const
 
bool IsOn (ObjectGuid who) const
 
bool IsBanned (ObjectGuid guid) const
 
void UpdateChannelInDB () const
 
void UpdateChannelUseageInDB () const
 
void AddChannelBanToDB (ObjectGuid guid, uint32 time) const
 
void RemoveChannelBanFromDB (ObjectGuid guid) const
 
uint8 GetPlayerFlags (ObjectGuid guid) const
 
void SetModerator (ObjectGuid guid, bool set)
 
void SetMute (ObjectGuid guid, bool set)
 

Private Attributes

bool _announce
 
bool _moderation
 
bool _ownership
 
bool _IsSaved
 
bool _isOwnerGM
 
uint8 _flags
 
uint32 _channelId
 
uint32 _channelDBId
 
TeamId _teamId
 
ObjectGuid _ownerGUID
 
std::string _name
 
std::string _password
 
ChannelRights _channelRights
 
PlayerContainer playersStore
 
BannedContainer bannedStore
 
PlayersWatchingContainer playersWatchingStore
 

Detailed Description

Member Typedef Documentation

◆ BannedContainer

typedef std::unordered_map<ObjectGuid, uint32> Channel::BannedContainer
private

◆ PlayerContainer

typedef std::unordered_map<ObjectGuid, PlayerInfo> Channel::PlayerContainer
private

◆ PlayersWatchingContainer

typedef std::unordered_set<Player*> Channel::PlayersWatchingContainer
private

Constructor & Destructor Documentation

◆ Channel()

Channel::Channel ( std::string const &  name,
uint32  channel_id,
uint32  channelDBId,
TeamId  teamId = TEAM_NEUTRAL,
bool  announce = true,
bool  ownership = true 
)
29 :
30 _announce(announce),
31 _ownership(ownership),
32 _IsSaved(false),
33 _isOwnerGM(false),
34 _flags(0),
35 _channelId(channelId),
36 _channelDBId(channelDBId),
37 _teamId(teamId),
38 _name(name),
39 _password("")
40{
41 // set special flags if built-in channel
42 if (ChatChannelsEntry const* ch = sChatChannelsStore.LookupEntry(channelId)) // check whether it's a built-in channel
43 {
44 _announce = false; // no join/leave announces
45 _ownership = false; // no ownership handout
46
47 _flags |= CHANNEL_FLAG_GENERAL; // for all built-in channels
48
49 if (ch->flags & CHANNEL_DBC_FLAG_TRADE) // for trade channel
51
52 if (ch->flags & CHANNEL_DBC_FLAG_CITY_ONLY2) // for city only channels
54
55 if (ch->flags & CHANNEL_DBC_FLAG_LFG) // for LFG channel
57 else // for all other channels
59 }
60 else // it's custom channel
61 {
63
64 // pussywizard:
67 _announce = false;
69 _announce = true;
71 _ownership = false;
73 return;
74
75 _IsSaved = true;
76
77 // Xinef: loading
78 if (channelDBId > 0)
79 return;
80
81 // If storing custom channels in the db is enabled either load or save the channel
82 if (sWorld->getBoolConfig(CONFIG_PRESERVE_CUSTOM_CHANNELS))
83 {
85
87 stmt->SetData(0, _channelDBId);
88 stmt->SetData(1, name);
89 stmt->SetData(2, _teamId);
90 stmt->SetData(3, _announce);
91 CharacterDatabase.Execute(stmt);
92 }
93 }
94}
@ CHANNEL_FLAG_TRADE
Definition Channel.h:77
@ CHANNEL_FLAG_NOT_LFG
Definition Channel.h:78
@ CHANNEL_FLAG_GENERAL
Definition Channel.h:79
@ CHANNEL_FLAG_CUSTOM
Definition Channel.h:75
@ CHANNEL_FLAG_LFG
Definition Channel.h:81
@ CHANNEL_FLAG_CITY
Definition Channel.h:80
@ CHANNEL_DBC_FLAG_TRADE
Definition Channel.h:96
@ CHANNEL_DBC_FLAG_CITY_ONLY2
Definition Channel.h:98
@ CHANNEL_DBC_FLAG_LFG
Definition Channel.h:101
@ CHANNEL_RIGHT_FORCE_NO_ANNOUNCEMENTS
Definition Channel.h:132
@ CHANNEL_RIGHT_DONT_PRESERVE
Definition Channel.h:140
@ CHANNEL_RIGHT_FORCE_ANNOUNCEMENTS
Definition Channel.h:133
@ CHANNEL_RIGHT_NO_OWNERSHIP
Definition Channel.h:134
@ CHAR_INS_CHANNEL
Definition CharacterDatabase.h:183
DBCStorage< ChatChannelsEntry > sChatChannelsStore(ChatChannelsEntryfmt)
DatabaseWorkerPool< CharacterDatabaseConnection > CharacterDatabase
Accessor to the character database.
Definition DatabaseEnv.cpp:21
@ CONFIG_PRESERVE_CUSTOM_CHANNELS
Definition IWorld.h:136
static uint32 _channelIdMax
Definition ChannelMgr.h:48
static const ChannelRights & GetChannelRightsFor(const std::string &name)
Definition ChannelMgr.cpp:208
uint32 flags
Definition Channel.h:123
uint32 _channelId
Definition Channel.h:326
bool _isOwnerGM
Definition Channel.h:324
ChannelRights _channelRights
Definition Channel.h:332
bool _announce
Definition Channel.h:320
uint8 _flags
Definition Channel.h:325
bool _ownership
Definition Channel.h:322
std::string _password
Definition Channel.h:331
uint32 _channelDBId
Definition Channel.h:327
TeamId _teamId
Definition Channel.h:328
std::string _name
Definition Channel.h:330
bool _IsSaved
Definition Channel.h:323
Acore::Types::is_default< T > SetData(const uint8 index, T value)
Definition PreparedStatement.h:77
Definition PreparedStatement.h:157
#define sWorld
Definition World.h:363
Definition DBCStructure.h:642

References _announce, _channelDBId, ChannelMgr::_channelIdMax, _channelRights, _flags, _IsSaved, _name, _ownership, _teamId, CHANNEL_DBC_FLAG_CITY_ONLY2, CHANNEL_DBC_FLAG_LFG, CHANNEL_DBC_FLAG_TRADE, CHANNEL_FLAG_CITY, CHANNEL_FLAG_CUSTOM, CHANNEL_FLAG_GENERAL, CHANNEL_FLAG_LFG, CHANNEL_FLAG_NOT_LFG, CHANNEL_FLAG_TRADE, CHANNEL_RIGHT_DONT_PRESERVE, CHANNEL_RIGHT_FORCE_ANNOUNCEMENTS, CHANNEL_RIGHT_FORCE_NO_ANNOUNCEMENTS, CHANNEL_RIGHT_NO_OWNERSHIP, CHAR_INS_CHANNEL, CharacterDatabase, CONFIG_PRESERVE_CUSTOM_CHANNELS, ChannelRights::flags, ChannelMgr::GetChannelRightsFor(), sChatChannelsStore, PreparedStatementBase::SetData(), and sWorld.

Member Function Documentation

◆ AddBan()

void Channel::AddBan ( ObjectGuid  guid,
uint32  time 
)
inline
196{ bannedStore[guid] = time; }
BannedContainer bannedStore
Definition Channel.h:334

References bannedStore.

Referenced by ChannelMgr::LoadChannels().

◆ AddChannelBanToDB()

void Channel::AddChannelBanToDB ( ObjectGuid  guid,
uint32  time 
) const
private
124{
126 stmt->SetData(0, _channelDBId);
127 stmt->SetData(1, guid.GetCounter());
128 stmt->SetData(2, time);
129 CharacterDatabase.Execute(stmt);
130}
@ CHAR_INS_CHANNEL_BAN
Definition CharacterDatabase.h:189
LowType GetCounter() const
Definition ObjectGuid.h:145

References _channelDBId, CHAR_INS_CHANNEL_BAN, CharacterDatabase, ObjectGuid::GetCounter(), and PreparedStatementBase::SetData().

Referenced by KickOrBan().

◆ AddWatching()

void Channel::AddWatching ( Player p)
1208{
1209 if (!IsOn(p->GetGUID()))
1210 return;
1211 playersWatchingStore.insert(p);
1212}
PlayersWatchingContainer playersWatchingStore
Definition Channel.h:335
bool IsOn(ObjectGuid who) const
Definition Channel.h:272
static ObjectGuid GetGUID(Object const *o)
Definition Object.h:112

References Object::GetGUID(), IsOn(), and playersWatchingStore.

◆ Announce()

void Channel::Announce ( Player const *  player)
725{
726 ObjectGuid guid = player->GetGUID();
727
728 if (!IsOn(guid))
729 {
730 WorldPacket data;
731 MakeNotMember(&data);
732 SendToOne(&data, guid);
733 return;
734 }
735
736 if (!playersStore[guid].IsModerator() && !player->GetSession()->IsGMAccount())
737 {
738 WorldPacket data;
739 MakeNotModerator(&data);
740 SendToOne(&data, guid);
741 return;
742 }
743
745 {
746 WorldPacket data;
747 MakeNotModerator(&data);
748 SendToOne(&data, guid);
749 return;
750 }
751
753
754 WorldPacket data;
755 if (_announce)
756 MakeAnnouncementsOn(&data, guid);
757 else
758 MakeAnnouncementsOff(&data, guid);
759 SendToAll(&data);
760
762}
void MakeNotMember(WorldPacket *data)
Definition Channel.cpp:985
void MakeAnnouncementsOn(WorldPacket *data, ObjectGuid guid)
Definition Channel.cpp:1037
void SendToOne(WorldPacket *data, ObjectGuid who)
Definition Channel.cpp:921
void UpdateChannelInDB() const
Definition Channel.cpp:102
PlayerContainer playersStore
Definition Channel.h:333
void MakeNotModerator(WorldPacket *data)
Definition Channel.cpp:990
void MakeAnnouncementsOff(WorldPacket *data, ObjectGuid guid)
Definition Channel.cpp:1043
void SendToAll(WorldPacket *data, ObjectGuid guid=ObjectGuid::Empty)
Definition Channel.cpp:907
Definition ObjectGuid.h:118
Definition WorldPacket.h:26

References _announce, _channelRights, CHANNEL_RIGHT_FORCE_ANNOUNCEMENTS, CHANNEL_RIGHT_FORCE_NO_ANNOUNCEMENTS, ChannelRights::flags, Object::GetGUID(), Player::GetSession(), WorldSession::IsGMAccount(), IsOn(), MakeAnnouncementsOff(), MakeAnnouncementsOn(), MakeNotMember(), MakeNotModerator(), playersStore, SendToAll(), SendToOne(), and UpdateChannelInDB().

◆ Ban()

void Channel::Ban ( Player const *  player,
std::string const &  badname 
)
inline
195{ KickOrBan(player, badname, true); }
void KickOrBan(Player const *player, std::string const &badname, bool ban)
Definition Channel.cpp:315

References KickOrBan().

◆ CleanOldChannelsInDB()

void Channel::CleanOldChannelsInDB ( )
static
141{
142 if (sWorld->getIntConfig(CONFIG_PRESERVE_CUSTOM_CHANNEL_DURATION) > 0)
143 {
144 CharacterDatabaseTransaction trans = CharacterDatabase.BeginTransaction();
145
148 trans->Append(stmt);
149
150 stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_OLD_CHANNELS_BANS);
151 trans->Append(stmt);
152
153 CharacterDatabase.CommitTransaction(trans);
154 }
155}
@ CHAR_DEL_OLD_CHANNELS_BANS
Definition CharacterDatabase.h:188
@ CHAR_DEL_OLD_CHANNELS
Definition CharacterDatabase.h:187
constexpr auto DAY
Definition Common.h:49
SQLTransaction< CharacterDatabaseConnection > CharacterDatabaseTransaction
Definition DatabaseEnvFwd.h:69
@ CONFIG_PRESERVE_CUSTOM_CHANNEL_DURATION
Definition IWorld.h:364

References CHAR_DEL_OLD_CHANNELS, CHAR_DEL_OLD_CHANNELS_BANS, CharacterDatabase, CONFIG_PRESERVE_CUSTOM_CHANNEL_DURATION, DAY, PreparedStatementBase::SetData(), and sWorld.

Referenced by World::SetInitialWorldSettings().

◆ DeVoice()

void Channel::DeVoice ( ObjectGuid  guid1,
ObjectGuid  guid2 
)
943{
944}

◆ FlagsNotify()

void Channel::FlagsNotify ( Player p)
1191{
1193 return;
1195 return;
1196
1197 WorldPacket data(SMSG_USERLIST_UPDATE, 8 + 1 + 1 + 4 + GetName().size());
1198 data << p->GetGUID();
1199 data << uint8(GetPlayerFlags(p->GetGUID()));
1200 data << uint8(GetFlags());
1201 data << uint32(GetNumPlayers());
1202 data << GetName();
1203
1204 SendToAllWatching(&data);
1205}
@ CHANNEL_RIGHT_CANT_SPEAK
Definition Channel.h:135
std::uint8_t uint8
Definition Define.h:109
std::uint32_t uint32
Definition Define.h:107
void SendToAllWatching(WorldPacket *data)
Definition Channel.cpp:927
std::string const & GetName() const
Definition Channel.h:179
uint8 GetPlayerFlags(ObjectGuid guid) const
Definition Channel.h:280
uint32 GetNumPlayers() const
Definition Channel.h:187
uint8 GetFlags() const
Definition Channel.h:188
WorldSession * GetSession() const
Definition Player.h:2005
AccountTypes GetSecurity() const
Definition WorldSession.h:373
@ SMSG_USERLIST_UPDATE
Definition Opcodes.h:1040
bool IsPlayerAccount(uint32 gmlevel)
Definition AccountMgr.cpp:305

References _channelRights, CHANNEL_RIGHT_CANT_SPEAK, ChannelRights::flags, GetFlags(), Object::GetGUID(), GetName(), GetNumPlayers(), GetPlayerFlags(), WorldSession::GetSecurity(), Player::GetSession(), AccountMgr::IsPlayerAccount(), SendToAllWatching(), and SMSG_USERLIST_UPDATE.

Referenced by JoinChannel(), SetModerator(), and SetOwner().

◆ GetChannelDBId()

uint32 Channel::GetChannelDBId ( ) const
inline
181{ return _channelDBId; }

References _channelDBId.

◆ GetChannelId()

uint32 Channel::GetChannelId ( ) const
inline
180{ return _channelId; }

References _channelId.

Referenced by MakeYouJoined(), and MakeYouLeft().

◆ GetFlags()

uint8 Channel::GetFlags ( ) const
inline
188{ return _flags; }

References _flags.

Referenced by FlagsNotify(), JoinNotify(), LeaveNotify(), List(), and MakeYouJoined().

◆ GetName()

std::string const & Channel::GetName ( ) const
inline

◆ GetNumPlayers()

uint32 Channel::GetNumPlayers ( ) const
inline
187{ return playersStore.size(); }

References playersStore.

Referenced by FlagsNotify(), JoinNotify(), and LeaveNotify().

◆ GetPassword()

std::string const & Channel::GetPassword ( ) const
inline
185{ return _password; }

References _password.

◆ GetPlayerFlags()

uint8 Channel::GetPlayerFlags ( ObjectGuid  guid) const
inlineprivate
281 {
282 PlayerContainer::const_iterator itr = playersStore.find(guid);
283 return itr != playersStore.end() ? itr->second.flags : 0;
284 }

References playersStore.

Referenced by FlagsNotify(), JoinNotify(), and MakeModeChange().

◆ HasFlag()

bool Channel::HasFlag ( uint8  flag) const
inline
189{ return _flags & flag; }

References _flags.

Referenced by IsLFG(), and ChatLogScript::OnPlayerChat().

◆ Invite()

void Channel::Invite ( Player const *  player,
std::string const &  newp 
)
806{
807 ObjectGuid guid = player->GetGUID();
808
809 if (!IsOn(guid))
810 {
811 WorldPacket data;
812 MakeNotMember(&data);
813 SendToOne(&data, guid);
814 return;
815 }
816
817 Player* newp = ObjectAccessor::FindPlayerByName(newname, false);
818 if (!newp || !newp->isGMVisible())
819 {
820 WorldPacket data;
821 MakePlayerNotFound(&data, newname);
822 SendToOne(&data, guid);
823 return;
824 }
825
826 if (IsBanned(newp->GetGUID()))
827 {
828 WorldPacket data;
829 MakePlayerInviteBanned(&data, newname);
830 SendToOne(&data, guid);
831 return;
832 }
833
834 if (newp->GetTeamId() != player->GetTeamId())
835 {
836 WorldPacket data;
838 SendToOne(&data, guid);
839 return;
840 }
841
842 if (IsOn(newp->GetGUID()))
843 {
844 WorldPacket data;
845 MakePlayerAlreadyMember(&data, newp->GetGUID());
846 SendToOne(&data, guid);
847 return;
848 }
849
850 if (!newp->GetSocial()->HasIgnore(guid))
851 {
852 WorldPacket data;
853 MakeInvite(&data, guid);
854 SendToOne(&data, newp->GetGUID());
855 data.clear();
856 }
857
858 WorldPacket data;
859 MakePlayerInvited(&data, newp->GetName());
860 SendToOne(&data, guid);
861}
void clear()
Definition ByteBuffer.h:122
void MakePlayerNotFound(WorldPacket *data, std::string const &name)
Definition Channel.cpp:1007
void MakePlayerInvited(WorldPacket *data, std::string const &name)
Definition Channel.cpp:1118
void MakePlayerInviteBanned(WorldPacket *data, std::string const &name)
Definition Channel.cpp:1124
void MakeInviteWrongFaction(WorldPacket *data)
Definition Channel.cpp:1098
void MakeInvite(WorldPacket *data, ObjectGuid guid)
Definition Channel.cpp:1092
void MakePlayerAlreadyMember(WorldPacket *data, ObjectGuid guid)
Definition Channel.cpp:1086
bool IsBanned(ObjectGuid guid) const
Definition Channel.cpp:96
bool HasIgnore(ObjectGuid ignore_guid) const
Definition SocialMgr.cpp:193
Definition Player.h:1081
bool isGMVisible() const
Definition Player.h:1181
TeamId GetTeamId(bool original=false) const
Definition Player.h:2116
PlayerSocial * GetSocial()
Definition Player.h:1158
std::string const & GetName() const
Definition Object.h:463
Player * FindPlayerByName(std::string const &name, bool checkInWorld=true)
Definition ObjectAccessor.cpp:271

References ByteBuffer::clear(), ObjectAccessor::FindPlayerByName(), Object::GetGUID(), WorldObject::GetName(), Player::GetSocial(), Player::GetTeamId(), PlayerSocial::HasIgnore(), IsBanned(), Player::isGMVisible(), IsOn(), MakeInvite(), MakeInviteWrongFaction(), MakeNotMember(), MakePlayerAlreadyMember(), MakePlayerInviteBanned(), MakePlayerInvited(), MakePlayerNotFound(), and SendToOne().

◆ IsAnnounce()

bool Channel::IsAnnounce ( ) const
inline
183{ return _announce; }

References _announce.

◆ IsBanned()

bool Channel::IsBanned ( ObjectGuid  guid) const
private
97{
98 BannedContainer::const_iterator itr = bannedStore.find(guid);
99 return itr != bannedStore.end() && itr->second > GameTime::GetGameTime().count();
100}
Seconds GetGameTime()
Definition GameTime.cpp:38

References bannedStore, and GameTime::GetGameTime().

Referenced by Invite(), JoinChannel(), KickOrBan(), UnBan(), and UnBan().

◆ IsConstant()

bool Channel::IsConstant ( ) const
inline
182{ return _channelId != 0; }

References _channelId.

Referenced by JoinChannel(), LeaveChannel(), MakeChannelOwner(), and MakeYouLeft().

◆ IsLFG()

bool Channel::IsLFG ( ) const
inline
184{ return HasFlag(CHANNEL_FLAG_LFG); }
bool HasFlag(uint8 flag) const
Definition Channel.h:189

References CHANNEL_FLAG_LFG, and HasFlag().

Referenced by JoinChannel().

◆ IsOn()

bool Channel::IsOn ( ObjectGuid  who) const
inlineprivate

◆ JoinChannel()

void Channel::JoinChannel ( Player player,
std::string const &  pass 
)
158{
159 ObjectGuid guid = player->GetGUID();
160 if (IsOn(guid))
161 {
162 // Do not send error message for built-in channels
163 if (!IsConstant())
164 {
165 WorldPacket data;
166 MakePlayerAlreadyMember(&data, guid);
167 SendToOne(&data, guid);
168 }
169 return;
170 }
171
172 if (IsBanned(guid))
173 {
174 WorldPacket data;
175 MakeBanned(&data);
176 SendToOne(&data, guid);
177 return;
178 }
179
180 if (!_password.empty() && pass != _password)
181 {
182 WorldPacket data;
183 MakeWrongPassword(&data);
184 SendToOne(&data, guid);
185 return;
186 }
187
188 if (IsLFG() && sWorld->getBoolConfig(CONFIG_RESTRICTED_LFG_CHANNEL) && !player->IsUsingLfg())
189 {
190 WorldPacket data;
191 MakeNotInLfg(&data);
192 SendToOne(&data, guid);
193 return;
194 }
195
196 player->JoinedChannel(this);
197
198 if (_announce && ShouldAnnouncePlayer(player))
199 {
200 WorldPacket data;
201 MakeJoined(&data, guid);
202 SendToAll(&data);
203 }
204
205 PlayerInfo pinfo;
206 pinfo.player = guid;
207 pinfo.flags = MEMBER_FLAG_NONE;
208 pinfo.plrPtr = player;
209
210 playersStore[guid] = pinfo;
211
212 if (_channelRights.joinMessage.length())
214
215 WorldPacket data;
216 MakeYouJoined(&data);
217 SendToOne(&data, guid);
218
219 JoinNotify(player);
220
221 playersStore[guid].SetOwnerGM(player->GetSession()->IsGMAccount());
222
223 // Custom channel handling
224 if (!IsConstant())
225 {
226 // Update last_used timestamp in db
227 if (!playersStore.empty())
229
231 {
232 playersStore[guid].SetModerator(true);
233 FlagsNotify(player);
234 }
235
236 // If the channel has no owner yet and ownership is allowed, set the new owner.
237 // If the channel owner is a GM and the config SilentGMJoinChannel is enabled, set the new owner
239 {
240 _isOwnerGM = playersStore[guid].IsOwnerGM();
241 SetOwner(guid, false);
242 }
243
245 playersStore[guid].SetMuted(true);
246 }
247}
@ MEMBER_FLAG_NONE
Definition Channel.h:107
@ CONFIG_SILENTLY_GM_JOIN_TO_CHANNEL
Definition IWorld.h:97
@ CONFIG_RESTRICTED_LFG_CHANNEL
Definition IWorld.h:96
std::set< uint32 > moderators
Definition Channel.h:127
std::string joinMessage
Definition Channel.h:125
bool IsConstant() const
Definition Channel.h:182
void MakeJoined(WorldPacket *data, ObjectGuid guid)
Definition Channel.cpp:953
void JoinNotify(Player *p)
Definition Channel.cpp:1157
bool IsLFG() const
Definition Channel.h:184
ObjectGuid _ownerGUID
Definition Channel.h:329
void SetOwner(ObjectGuid guid, bool exclaim=true)
Definition Channel.cpp:863
bool ShouldAnnouncePlayer(Player const *player) const
Definition Channel.cpp:933
void MakeYouJoined(WorldPacket *data)
Definition Channel.cpp:965
void MakeNotInLfg(WorldPacket *data)
Definition Channel.cpp:1140
void MakeBanned(WorldPacket *data)
Definition Channel.cpp:1061
void MakeWrongPassword(WorldPacket *data)
Definition Channel.cpp:980
void UpdateChannelUseageInDB() const
Definition Channel.cpp:116
void FlagsNotify(Player *p)
Definition Channel.cpp:1190
Definition Chat.h:37
void PSendSysMessage(std::string_view str, bool escapeCharacters=false)
Definition Chat.cpp:211
bool IsUsingLfg()
Definition Player.cpp:13126
void JoinedChannel(Channel *c)
Definition Player.cpp:5020
bool IsGMAccount() const
Definition WorldSession.cpp:180
uint32 GetAccountId() const
Definition WorldSession.h:375
Definition Player.h:340

References _announce, _channelRights, _isOwnerGM, _ownerGUID, _ownership, _password, CHANNEL_RIGHT_CANT_SPEAK, CONFIG_RESTRICTED_LFG_CHANNEL, CONFIG_SILENTLY_GM_JOIN_TO_CHANNEL, ChannelRights::flags, Channel::PlayerInfo::flags, FlagsNotify(), WorldSession::GetAccountId(), Object::GetGUID(), Player::GetSession(), IsBanned(), IsConstant(), WorldSession::IsGMAccount(), IsLFG(), IsOn(), Player::IsUsingLfg(), Player::JoinedChannel(), ChannelRights::joinMessage, JoinNotify(), MakeBanned(), MakeJoined(), MakeNotInLfg(), MakePlayerAlreadyMember(), MakeWrongPassword(), MakeYouJoined(), MEMBER_FLAG_NONE, ChannelRights::moderators, Channel::PlayerInfo::player, playersStore, Channel::PlayerInfo::plrPtr, ChatHandler::PSendSysMessage(), SendToAll(), SendToOne(), SetOwner(), ShouldAnnouncePlayer(), sWorld, and UpdateChannelUseageInDB().

Referenced by Player::UpdateLFGChannel(), and Player::UpdateLocalChannels().

◆ JoinNotify()

void Channel::JoinNotify ( Player p)
1158{
1160 return;
1162 return;
1163
1164 WorldPacket data(SMSG_USERLIST_ADD, 8 + 1 + 1 + 4 + GetName().size());
1165 data << p->GetGUID();
1166 data << uint8(GetPlayerFlags(p->GetGUID()));
1167 data << uint8(GetFlags());
1168 data << uint32(GetNumPlayers());
1169 data << GetName();
1170
1171 SendToAllWatching(&data);
1172}
@ SMSG_USERLIST_ADD
Definition Opcodes.h:1038

References _channelRights, CHANNEL_RIGHT_CANT_SPEAK, ChannelRights::flags, GetFlags(), Object::GetGUID(), GetName(), GetNumPlayers(), GetPlayerFlags(), WorldSession::GetSecurity(), Player::GetSession(), AccountMgr::IsPlayerAccount(), SendToAllWatching(), and SMSG_USERLIST_ADD.

Referenced by JoinChannel().

◆ Kick()

void Channel::Kick ( Player const *  player,
std::string const &  badname 
)
inline
194{ KickOrBan(player, badname, false); }

References KickOrBan().

◆ KickOrBan()

void Channel::KickOrBan ( Player const *  player,
std::string const &  badname,
bool  ban 
)
316{
317 ObjectGuid good = player->GetGUID();
318
319 if (!IsOn(good))
320 {
321 WorldPacket data;
322 MakeNotMember(&data);
323 SendToOne(&data, good);
324 return;
325 }
326
327 if (!playersStore[good].IsModerator() && !player->GetSession()->IsGMAccount())
328 {
329 WorldPacket data;
330 MakeNotModerator(&data);
331 SendToOne(&data, good);
332 return;
333 }
334
335 bool banOffline = false; // pussywizard
336 bool isGoodConstantModerator = _channelRights.moderators.find(player->GetSession()->GetAccountId()) != _channelRights.moderators.end();
337
338 ObjectGuid victim;
339 uint32 badAccId = 0;
340 Player* bad = ObjectAccessor::FindPlayerByName(badname, false);
341 if (bad)
342 {
343 victim = bad->GetGUID();
344 badAccId = bad->GetSession()->GetAccountId();
345 }
346
347 bool isOnChannel = victim && IsOn(victim);
348 if (!isOnChannel)
349 {
350 if (ban && (player->GetSession()->IsGMAccount() || isGoodConstantModerator))
351 {
352 if (ObjectGuid guid = sCharacterCache->GetCharacterGuidByName(badname))
353 {
354 if (CharacterCacheEntry const* gpd = sCharacterCache->GetCharacterCacheByGuid(guid))
355 {
356 if (Player::TeamIdForRace(gpd->Race) == Player::TeamIdForRace(player->getRace()))
357 {
358 banOffline = true;
359 victim = guid;
360 badAccId = gpd->AccountId;
361 }
362 else
363 {
364 ChatHandler(player->GetSession()).PSendSysMessage("Character {} has other faction!", badname);
365 return;
366 }
367 }
368 }
369
370 if (!banOffline)
371 {
372 WorldPacket data;
373 MakePlayerNotFound(&data, badname);
374 SendToOne(&data, good);
375 return;
376 }
377 }
378 else
379 {
380 WorldPacket data;
381 MakePlayerNotFound(&data, badname);
382 SendToOne(&data, good);
383 return;
384 }
385 }
386
387 bool changeowner = _ownerGUID == victim;
388 bool isBadConstantModerator = _channelRights.moderators.find(badAccId) != _channelRights.moderators.end();
389
390 if (!player->GetSession()->IsGMAccount() && !isGoodConstantModerator)
391 {
392 if (changeowner && good != _ownerGUID)
393 {
394 WorldPacket data;
395 MakeNotOwner(&data);
396 SendToOne(&data, good);
397 return;
398 }
399
401 {
402 WorldPacket data;
403 MakeNotModerator(&data);
404 SendToOne(&data, good);
405 return;
406 }
407
408 if (isBadConstantModerator || bad->GetSession()->IsGMAccount())
409 {
410 WorldPacket data;
411 MakeNotModerator(&data);
412 SendToOne(&data, good);
413 return;
414 }
415 }
416
417 if (ban)
418 {
419 if (!IsBanned(victim))
420 {
423
424 if (ShouldAnnouncePlayer(player))
425 {
426 WorldPacket data;
427 MakePlayerBanned(&data, victim, good);
428 SendToAll(&data);
429 }
430 }
431 }
432 else if (ShouldAnnouncePlayer(player))
433 {
434 WorldPacket data;
435 MakePlayerKicked(&data, victim, good);
436 SendToAll(&data);
437 }
438
439 if (isOnChannel)
440 {
441 playersStore.erase(victim);
442 bad->LeftChannel(this);
443 RemoveWatching(bad);
444 LeaveNotify(bad);
445 }
446
447 if (changeowner && _ownership)
448 {
449 if (good != victim)
450 SetOwner(good);
451 else if (!playersStore.empty())
452 {
453 ObjectGuid newowner;
454 for (Channel::PlayerContainer::const_iterator itr = playersStore.begin(); itr != playersStore.end(); ++itr)
455 {
456 newowner = itr->second.player;
457 if (!itr->second.plrPtr->GetSession()->GetSecurity())
458 break;
459 }
460 SetOwner(newowner);
461 }
462 else
464 }
465}
#define CHANNEL_BAN_DURATION
Definition Channel.h:27
@ CHANNEL_RIGHT_CANT_BAN
Definition Channel.h:136
@ CHANNEL_RIGHT_CANT_KICK
Definition Channel.h:137
#define sCharacterCache
Definition CharacterCache.h:83
void RemoveWatching(Player *p)
Definition Channel.cpp:1214
void MakePlayerBanned(WorldPacket *data, ObjectGuid bad, ObjectGuid good)
Definition Channel.cpp:1066
void MakeNotOwner(WorldPacket *data)
Definition Channel.cpp:1013
void AddChannelBanToDB(ObjectGuid guid, uint32 time) const
Definition Channel.cpp:123
void MakePlayerKicked(WorldPacket *data, ObjectGuid bad, ObjectGuid good)
Definition Channel.cpp:1054
void LeaveNotify(Player *p)
Definition Channel.cpp:1174
static ObjectGuid const Empty
Definition ObjectGuid.h:120
static TeamId TeamIdForRace(uint8 race)
Definition Player.cpp:5871
void LeftChannel(Channel *c)
Definition Player.cpp:5025
Definition CharacterCache.h:28

References _channelRights, _ownerGUID, _ownership, AddChannelBanToDB(), bannedStore, CHANNEL_BAN_DURATION, CHANNEL_RIGHT_CANT_BAN, CHANNEL_RIGHT_CANT_KICK, ObjectGuid::Empty, ObjectAccessor::FindPlayerByName(), ChannelRights::flags, WorldSession::GetAccountId(), GameTime::GetGameTime(), Object::GetGUID(), Unit::getRace(), Player::GetSession(), IsBanned(), WorldSession::IsGMAccount(), IsOn(), LeaveNotify(), Player::LeftChannel(), MakeNotMember(), MakeNotModerator(), MakeNotOwner(), MakePlayerBanned(), MakePlayerKicked(), MakePlayerNotFound(), ChannelRights::moderators, playersStore, ChatHandler::PSendSysMessage(), RemoveWatching(), sCharacterCache, SendToAll(), SendToOne(), SetOwner(), ShouldAnnouncePlayer(), and Player::TeamIdForRace().

Referenced by Ban(), and Kick().

◆ LeaveChannel()

void Channel::LeaveChannel ( Player player,
bool  send = true 
)
250{
251 ObjectGuid guid = player->GetGUID();
252 if (!IsOn(guid))
253 {
254 if (send)
255 {
256 WorldPacket data;
257 MakeNotMember(&data);
258 SendToOne(&data, guid);
259 }
260 return;
261 }
262
263 if (send)
264 {
265 WorldPacket data;
266 MakeYouLeft(&data);
267 SendToOne(&data, guid);
268 player->LeftChannel(this);
269 data.clear();
270 }
271
272 bool changeowner = playersStore[guid].IsOwner();
273
274 playersStore.erase(guid);
275 if (_announce && ShouldAnnouncePlayer(player))
276 {
277 WorldPacket data;
278 MakeLeft(&data, guid);
279 SendToAll(&data);
280 }
281
282 RemoveWatching(player);
283 LeaveNotify(player);
284
285 if (!IsConstant())
286 {
287 // Update last_used timestamp in db
289
290 // If the channel owner left and there are still playersStore inside, pick a new owner
291 if (changeowner && _ownership)
292 {
293 if (!playersStore.empty())
294 {
295 ObjectGuid newowner;
296 for (Channel::PlayerContainer::const_iterator itr = playersStore.begin(); itr != playersStore.end(); ++itr)
297 {
298 newowner = itr->second.player;
299 if (itr->second.plrPtr->GetSession()->IsGMAccount())
300 _isOwnerGM = true;
301 else
302 _isOwnerGM = false;
303 if (!itr->second.plrPtr->GetSession()->GetSecurity())
304 break;
305 }
306 SetOwner(newowner);
307 // if the new owner is invisible gm, set flag to automatically choose a new owner
308 }
309 else
311 }
312 }
313}
void MakeYouLeft(WorldPacket *data)
Definition Channel.cpp:973
void MakeLeft(WorldPacket *data, ObjectGuid guid)
Definition Channel.cpp:959

References _announce, _isOwnerGM, _ownership, ByteBuffer::clear(), ObjectGuid::Empty, Object::GetGUID(), IsConstant(), IsOn(), LeaveNotify(), Player::LeftChannel(), MakeLeft(), MakeNotMember(), MakeYouLeft(), playersStore, RemoveWatching(), SendToAll(), SendToOne(), SetOwner(), ShouldAnnouncePlayer(), and UpdateChannelUseageInDB().

Referenced by Player::CleanupChannels(), Player::UpdateLFGChannel(), and Player::UpdateLocalChannels().

◆ LeaveNotify()

void Channel::LeaveNotify ( Player p)
1175{
1177 return;
1179 return;
1180
1181 WorldPacket data(SMSG_USERLIST_REMOVE, 8 + 1 + 4 + GetName().size());
1182 data << p->GetGUID();
1183 data << uint8(GetFlags());
1184 data << uint32(GetNumPlayers());
1185 data << GetName();
1186
1187 SendToAllWatching(&data);
1188}
@ SMSG_USERLIST_REMOVE
Definition Opcodes.h:1039

References _channelRights, CHANNEL_RIGHT_CANT_SPEAK, ChannelRights::flags, GetFlags(), Object::GetGUID(), GetName(), GetNumPlayers(), WorldSession::GetSecurity(), Player::GetSession(), AccountMgr::IsPlayerAccount(), SendToAllWatching(), and SMSG_USERLIST_REMOVE.

Referenced by KickOrBan(), and LeaveChannel().

◆ List()

void Channel::List ( Player const *  player)
689{
690 ObjectGuid guid = player->GetGUID();
691
692 if (!IsOn(guid))
693 {
694 WorldPacket data;
695 MakeNotMember(&data);
696 SendToOne(&data, guid);
697 return;
698 }
699
700 LOG_DEBUG("chat.system", "SMSG_CHANNEL_LIST {} Channel: {}", player->GetSession()->GetPlayerInfo(), GetName());
701 WorldPacket data(SMSG_CHANNEL_LIST, 1 + (GetName().size() + 1) + 1 + 4 + playersStore.size() * (8 + 1));
702 data << uint8(1); // channel type?
703 data << GetName(); // channel name
704 data << uint8(GetFlags()); // channel flags?
705
706 std::size_t pos = data.wpos();
707 data << uint32(0); // size of list, placeholder
708
709 uint32 count = 0;
711 for (PlayerContainer::const_iterator i = playersStore.begin(); i != playersStore.end(); ++i)
712 if (AccountMgr::IsPlayerAccount(i->second.plrPtr->GetSession()->GetSecurity()))
713 {
714 data << i->first;
715 data << uint8(i->second.flags); // flags seems to be changed...
716 ++count;
717 }
718
719 data.put<uint32>(pos, count);
720
721 SendToOne(&data, guid);
722}
#define LOG_DEBUG(filterType__,...)
Definition Log.h:169
@ SMSG_CHANNEL_LIST
Definition Opcodes.h:185

References _channelRights, CHANNEL_RIGHT_CANT_SPEAK, ChannelRights::flags, GetFlags(), Object::GetGUID(), GetName(), WorldSession::GetPlayerInfo(), Player::GetSession(), IsOn(), AccountMgr::IsPlayerAccount(), LOG_DEBUG, MakeNotMember(), playersStore, ByteBuffer::put(), SendToOne(), SMSG_CHANNEL_LIST, and ByteBuffer::wpos().

◆ MakeAnnouncementsOff()

void Channel::MakeAnnouncementsOff ( WorldPacket data,
ObjectGuid  guid 
)
private
1044{
1046 *data << guid;
1047}
@ CHAT_ANNOUNCEMENTS_OFF_NOTICE
Definition Channel.h:48
void MakeNotifyPacket(WorldPacket *data, uint8 notify_type)
Definition Channel.cpp:946

References CHAT_ANNOUNCEMENTS_OFF_NOTICE, and MakeNotifyPacket().

Referenced by Announce().

◆ MakeAnnouncementsOn()

void Channel::MakeAnnouncementsOn ( WorldPacket data,
ObjectGuid  guid 
)
private
1038{
1040 *data << guid;
1041}
@ CHAT_ANNOUNCEMENTS_ON_NOTICE
Definition Channel.h:47

References CHAT_ANNOUNCEMENTS_ON_NOTICE, and MakeNotifyPacket().

Referenced by Announce().

◆ MakeBanned()

void Channel::MakeBanned ( WorldPacket data)
private
1062{
1064}
@ CHAT_BANNED_NOTICE
Definition Channel.h:53

References CHAT_BANNED_NOTICE, and MakeNotifyPacket().

Referenced by JoinChannel().

◆ MakeChannelOwner()

void Channel::MakeChannelOwner ( WorldPacket data)
private
1019{
1020 std::string name = "";
1021
1022 if (!sCharacterCache->GetCharacterNameByGuid(_ownerGUID, name) || name.empty())
1023 name = "PLAYER_NOT_FOUND";
1024
1026 *data << ((IsConstant() || !_ownerGUID) ? "Nobody" : name);
1027}
@ CHAT_CHANNEL_OWNER_NOTICE
Definition Channel.h:45

References _ownerGUID, CHAT_CHANNEL_OWNER_NOTICE, IsConstant(), MakeNotifyPacket(), and sCharacterCache.

Referenced by SendWhoOwner().

◆ MakeInvalidName()

void Channel::MakeInvalidName ( WorldPacket data)
private
1109{
1111}
@ CHAT_INVALID_NAME_NOTICE
Definition Channel.h:61

References CHAT_INVALID_NAME_NOTICE, and MakeNotifyPacket().

◆ MakeInvite()

void Channel::MakeInvite ( WorldPacket data,
ObjectGuid  guid 
)
private
1093{
1095 *data << guid;
1096}
@ CHAT_INVITE_NOTICE
Definition Channel.h:58

References CHAT_INVITE_NOTICE, and MakeNotifyPacket().

Referenced by Invite().

◆ MakeInviteWrongFaction()

void Channel::MakeInviteWrongFaction ( WorldPacket data)
private
1099{
1101}
@ CHAT_INVITE_WRONG_FACTION_NOTICE
Definition Channel.h:59

References CHAT_INVITE_WRONG_FACTION_NOTICE, and MakeNotifyPacket().

Referenced by Invite().

◆ MakeJoined()

void Channel::MakeJoined ( WorldPacket data,
ObjectGuid  guid 
)
private
954{
956 *data << guid;
957}
@ CHAT_JOINED_NOTICE
Definition Channel.h:32

References CHAT_JOINED_NOTICE, and MakeNotifyPacket().

Referenced by JoinChannel().

◆ MakeLeft()

void Channel::MakeLeft ( WorldPacket data,
ObjectGuid  guid 
)
private
960{
962 *data << guid;
963}
@ CHAT_LEFT_NOTICE
Definition Channel.h:33

References CHAT_LEFT_NOTICE, and MakeNotifyPacket().

Referenced by LeaveChannel().

◆ MakeModeChange()

void Channel::MakeModeChange ( WorldPacket data,
ObjectGuid  guid,
uint8  oldflags 
)
private
1030{
1032 *data << guid;
1033 *data << uint8(oldflags);
1034 *data << uint8(GetPlayerFlags(guid));
1035}
@ CHAT_MODE_CHANGE_NOTICE
Definition Channel.h:46

References CHAT_MODE_CHANGE_NOTICE, GetPlayerFlags(), and MakeNotifyPacket().

Referenced by SetModerator(), SetMute(), and SetOwner().

◆ MakeModerationOff()

void Channel::MakeModerationOff ( WorldPacket data,
ObjectGuid  guid 
)
private
1267{
1269 *data << guid;
1270}
@ CHAT_MODERATION_OFF_NOTICE
Definition Channel.h:50

References CHAT_MODERATION_OFF_NOTICE, and MakeNotifyPacket().

Referenced by ToggleModeration().

◆ MakeModerationOn()

void Channel::MakeModerationOn ( WorldPacket data,
ObjectGuid  guid 
)
private
1261{
1263 *data << guid;
1264}
@ CHAT_MODERATION_ON_NOTICE
Definition Channel.h:49

References CHAT_MODERATION_ON_NOTICE, and MakeNotifyPacket().

Referenced by ToggleModeration().

◆ MakeMuted()

void Channel::MakeMuted ( WorldPacket data)
private
1050{
1052}
@ CHAT_MUTED_NOTICE
Definition Channel.h:51

References CHAT_MUTED_NOTICE, and MakeNotifyPacket().

Referenced by Say().

◆ MakeNotifyPacket()

◆ MakeNotInArea()

void Channel::MakeNotInArea ( WorldPacket data)
private
1136{
1138}
@ CHAT_NOT_IN_AREA_NOTICE
Definition Channel.h:66

References CHAT_NOT_IN_AREA_NOTICE, and MakeNotifyPacket().

◆ MakeNotInLfg()

void Channel::MakeNotInLfg ( WorldPacket data)
private
1141{
1143}
@ CHAT_NOT_IN_LFG_NOTICE
Definition Channel.h:67

References CHAT_NOT_IN_LFG_NOTICE, and MakeNotifyPacket().

Referenced by JoinChannel().

◆ MakeNotMember()

void Channel::MakeNotMember ( WorldPacket data)
private

◆ MakeNotModerated()

void Channel::MakeNotModerated ( WorldPacket data)
private
1114{
1116}
@ CHAT_NOT_MODERATED_NOTICE
Definition Channel.h:62

References CHAT_NOT_MODERATED_NOTICE, and MakeNotifyPacket().

◆ MakeNotModerator()

void Channel::MakeNotModerator ( WorldPacket data)
private
991{
993}
@ CHAT_NOT_MODERATOR_NOTICE
Definition Channel.h:40

References CHAT_NOT_MODERATOR_NOTICE, and MakeNotifyPacket().

Referenced by Announce(), KickOrBan(), Password(), SetMode(), ToggleModeration(), and UnBan().

◆ MakeNotOwner()

void Channel::MakeNotOwner ( WorldPacket data)
private
1014{
1016}
@ CHAT_NOT_OWNER_NOTICE
Definition Channel.h:44

References CHAT_NOT_OWNER_NOTICE, and MakeNotifyPacket().

Referenced by KickOrBan(), SetMode(), and SetOwner().

◆ MakeOwnerChanged()

void Channel::MakeOwnerChanged ( WorldPacket data,
ObjectGuid  guid 
)
private
1002{
1004 *data << guid;
1005}
@ CHAT_OWNER_CHANGED_NOTICE
Definition Channel.h:42

References CHAT_OWNER_CHANGED_NOTICE, and MakeNotifyPacket().

Referenced by SetOwner().

◆ MakePasswordChanged()

void Channel::MakePasswordChanged ( WorldPacket data,
ObjectGuid  guid 
)
private
996{
998 *data << guid;
999}
@ CHAT_PASSWORD_CHANGED_NOTICE
Definition Channel.h:41

References CHAT_PASSWORD_CHANGED_NOTICE, and MakeNotifyPacket().

Referenced by Password().

◆ MakePlayerAlreadyMember()

void Channel::MakePlayerAlreadyMember ( WorldPacket data,
ObjectGuid  guid 
)
private
1087{
1089 *data << guid;
1090}
@ CHAT_PLAYER_ALREADY_MEMBER_NOTICE
Definition Channel.h:57

References CHAT_PLAYER_ALREADY_MEMBER_NOTICE, and MakeNotifyPacket().

Referenced by Invite(), and JoinChannel().

◆ MakePlayerBanned()

void Channel::MakePlayerBanned ( WorldPacket data,
ObjectGuid  bad,
ObjectGuid  good 
)
private
1067{
1069 *data << bad;
1070 *data << good;
1071}
@ CHAT_PLAYER_BANNED_NOTICE
Definition Channel.h:54

References CHAT_PLAYER_BANNED_NOTICE, and MakeNotifyPacket().

Referenced by KickOrBan().

◆ MakePlayerInviteBanned()

void Channel::MakePlayerInviteBanned ( WorldPacket data,
std::string const &  name 
)
private
1125{
1127 *data << name;
1128}
@ CHAT_PLAYER_INVITE_BANNED_NOTICE
Definition Channel.h:64

References CHAT_PLAYER_INVITE_BANNED_NOTICE, and MakeNotifyPacket().

Referenced by Invite().

◆ MakePlayerInvited()

void Channel::MakePlayerInvited ( WorldPacket data,
std::string const &  name 
)
private
1119{
1121 *data << name;
1122}
@ CHAT_PLAYER_INVITED_NOTICE
Definition Channel.h:63

References CHAT_PLAYER_INVITED_NOTICE, and MakeNotifyPacket().

Referenced by Invite().

◆ MakePlayerKicked()

void Channel::MakePlayerKicked ( WorldPacket data,
ObjectGuid  bad,
ObjectGuid  good 
)
private
1055{
1057 *data << bad;
1058 *data << good;
1059}
@ CHAT_PLAYER_KICKED_NOTICE
Definition Channel.h:52

References CHAT_PLAYER_KICKED_NOTICE, and MakeNotifyPacket().

Referenced by KickOrBan().

◆ MakePlayerNotBanned()

void Channel::MakePlayerNotBanned ( WorldPacket data,
std::string const &  name 
)
private
1081{
1083 *data << name;
1084}
@ CHAT_PLAYER_NOT_BANNED_NOTICE
Definition Channel.h:56

References CHAT_PLAYER_NOT_BANNED_NOTICE, and MakeNotifyPacket().

◆ MakePlayerNotFound()

void Channel::MakePlayerNotFound ( WorldPacket data,
std::string const &  name 
)
private
1008{
1010 *data << name;
1011}
@ CHAT_PLAYER_NOT_FOUND_NOTICE
Definition Channel.h:43

References CHAT_PLAYER_NOT_FOUND_NOTICE, and MakeNotifyPacket().

Referenced by Invite(), KickOrBan(), SetMode(), SetOwner(), and UnBan().

◆ MakePlayerUnbanned()

void Channel::MakePlayerUnbanned ( WorldPacket data,
ObjectGuid  bad,
ObjectGuid  good 
)
private
1074{
1076 *data << bad;
1077 *data << good;
1078}
@ CHAT_PLAYER_UNBANNED_NOTICE
Definition Channel.h:55

References CHAT_PLAYER_UNBANNED_NOTICE, and MakeNotifyPacket().

Referenced by UnBan().

◆ MakeThrottled()

void Channel::MakeThrottled ( WorldPacket data)
private
1131{
1133}
@ CHAT_THROTTLED_NOTICE
Definition Channel.h:65

References CHAT_THROTTLED_NOTICE, and MakeNotifyPacket().

◆ MakeVoiceOff()

void Channel::MakeVoiceOff ( WorldPacket data,
ObjectGuid  guid 
)
private
1152{
1154 *data << guid;
1155}
@ CHAT_VOICE_OFF_NOTICE
Definition Channel.h:69

References CHAT_VOICE_OFF_NOTICE, and MakeNotifyPacket().

◆ MakeVoiceOn()

void Channel::MakeVoiceOn ( WorldPacket data,
ObjectGuid  guid 
)
private
1146{
1148 *data << guid;
1149}
@ CHAT_VOICE_ON_NOTICE
Definition Channel.h:68

References CHAT_VOICE_ON_NOTICE, and MakeNotifyPacket().

◆ MakeWrongFaction()

void Channel::MakeWrongFaction ( WorldPacket data)
private
1104{
1106}
@ CHAT_WRONG_FACTION_NOTICE
Definition Channel.h:60

References CHAT_WRONG_FACTION_NOTICE, and MakeNotifyPacket().

◆ MakeWrongPassword()

void Channel::MakeWrongPassword ( WorldPacket data)
private
981{
983}
@ CHAT_WRONG_PASSWORD_NOTICE
Definition Channel.h:38

References CHAT_WRONG_PASSWORD_NOTICE, and MakeNotifyPacket().

Referenced by JoinChannel().

◆ MakeYouJoined()

void Channel::MakeYouJoined ( WorldPacket data)
private
966{
968 *data << uint8(GetFlags());
969 *data << uint32(GetChannelId());
970 *data << uint32(0);
971}
@ CHAT_YOU_JOINED_NOTICE
Definition Channel.h:35
uint32 GetChannelId() const
Definition Channel.h:180

References CHAT_YOU_JOINED_NOTICE, GetChannelId(), GetFlags(), and MakeNotifyPacket().

Referenced by JoinChannel().

◆ MakeYouLeft()

void Channel::MakeYouLeft ( WorldPacket data)
private
974{
976 *data << uint32(GetChannelId());
977 *data << uint8(IsConstant());
978}
@ CHAT_YOU_LEFT_NOTICE
Definition Channel.h:37

References CHAT_YOU_LEFT_NOTICE, GetChannelId(), IsConstant(), and MakeNotifyPacket().

Referenced by LeaveChannel().

◆ Password()

void Channel::Password ( Player const *  player,
std::string const &  pass 
)
535{
536 ObjectGuid guid = player->GetGUID();
537
538 ChatHandler chat(player->GetSession());
539 if (!IsOn(guid))
540 {
541 WorldPacket data;
542 MakeNotMember(&data);
543 SendToOne(&data, guid);
544 return;
545 }
546
547 if (!playersStore[guid].IsModerator() && !player->GetSession()->IsGMAccount())
548 {
549 WorldPacket data;
550 MakeNotModerator(&data);
551 SendToOne(&data, guid);
552 return;
553 }
554
556 {
557 WorldPacket data;
558 MakeNotModerator(&data);
559 SendToOne(&data, guid);
560 return;
561 }
562
563 _password = pass;
564
565 WorldPacket data;
566 MakePasswordChanged(&data, guid);
567 SendToAll(&data);
568
570}
@ CHANNEL_RIGHT_CANT_CHANGE_PASSWORD
Definition Channel.h:139
void MakePasswordChanged(WorldPacket *data, ObjectGuid guid)
Definition Channel.cpp:995

References _channelRights, _password, CHANNEL_RIGHT_CANT_CHANGE_PASSWORD, ChannelRights::flags, Object::GetGUID(), Player::GetSession(), WorldSession::IsGMAccount(), IsOn(), MakeNotMember(), MakeNotModerator(), MakePasswordChanged(), playersStore, SendToAll(), SendToOne(), and UpdateChannelInDB().

◆ RemoveChannelBanFromDB()

void Channel::RemoveChannelBanFromDB ( ObjectGuid  guid) const
private
133{
135 stmt->SetData(0, _channelDBId);
136 stmt->SetData(1, guid.GetCounter());
137 CharacterDatabase.Execute(stmt);
138}
@ CHAR_DEL_CHANNEL_BAN
Definition CharacterDatabase.h:190

References _channelDBId, CHAR_DEL_CHANNEL_BAN, CharacterDatabase, ObjectGuid::GetCounter(), and PreparedStatementBase::SetData().

Referenced by UnBan(), and UnBan().

◆ RemoveWatching()

void Channel::RemoveWatching ( Player p)
1215{
1216 PlayersWatchingContainer::iterator itr = playersWatchingStore.find(p);
1217 if (itr != playersWatchingStore.end())
1218 playersWatchingStore.erase(itr);
1219}

References playersWatchingStore.

Referenced by KickOrBan(), and LeaveChannel().

◆ Say()

void Channel::Say ( ObjectGuid  guid,
std::string const &  what,
uint32  lang 
)
765{
766 if (what.empty())
767 return;
768
770 lang = LANG_UNIVERSAL;
771
772 if (!IsOn(guid))
773 {
774 WorldPacket data;
775 MakeNotMember(&data);
776 SendToOne(&data, guid);
777 return;
778 }
779
780 PlayerInfo& pinfo = playersStore[guid];
781
782 if (pinfo.IsMuted())
783 {
784 WorldPacket data;
785 MakeMuted(&data);
786 SendToOne(&data, guid);
787 return;
788 }
789
790 Player* player = pinfo.plrPtr;
791 WorldPacket data;
792
793 if (player)
794 {
795 ChatHandler::BuildChatPacket(data, CHAT_MSG_CHANNEL, Language(lang), player, player, what, 0, _name);
796 }
797 else
798 {
799 ChatHandler::BuildChatPacket(data, CHAT_MSG_CHANNEL, Language(lang), guid, guid, what, 0, "", "", 0, false, _name);
800 }
801
802 SendToAll(&data, pinfo.IsModerator() ? ObjectGuid::Empty : guid);
803}
@ CONFIG_ALLOW_TWO_SIDE_INTERACTION_CHANNEL
Definition IWorld.h:72
@ CHAT_MSG_CHANNEL
Definition SharedDefines.h:3169
Language
Definition SharedDefines.h:734
@ LANG_UNIVERSAL
Definition SharedDefines.h:735
void MakeMuted(WorldPacket *data)
Definition Channel.cpp:1049
static std::size_t BuildChatPacket(WorldPacket &data, ChatMsg chatType, Language language, ObjectGuid senderGUID, ObjectGuid receiverGUID, std::string_view message, uint8 chatTag, std::string const &senderName="", std::string const &receiverName="", uint32 achievementId=0, bool gmMessage=false, std::string const &channelName="")
Definition Chat.cpp:265

References _name, ChatHandler::BuildChatPacket(), CHAT_MSG_CHANNEL, CONFIG_ALLOW_TWO_SIDE_INTERACTION_CHANNEL, ObjectGuid::Empty, Channel::PlayerInfo::IsModerator(), Channel::PlayerInfo::IsMuted(), IsOn(), LANG_UNIVERSAL, MakeMuted(), MakeNotMember(), playersStore, Channel::PlayerInfo::plrPtr, SendToAll(), SendToOne(), and sWorld.

◆ SendToAll()

void Channel::SendToAll ( WorldPacket data,
ObjectGuid  guid = ObjectGuid::Empty 
)
private
908{
909 for (PlayerContainer::const_iterator i = playersStore.begin(); i != playersStore.end(); ++i)
910 if (!guid || !i->second.plrPtr->GetSocial()->HasIgnore(guid))
911 i->second.plrPtr->GetSession()->SendPacket(data);
912}

References playersStore.

Referenced by Announce(), JoinChannel(), KickOrBan(), LeaveChannel(), Password(), Say(), SetModerator(), SetMute(), SetOwner(), ToggleModeration(), and UnBan().

◆ SendToAllButOne()

void Channel::SendToAllButOne ( WorldPacket data,
ObjectGuid  who 
)
private
915{
916 for (PlayerContainer::const_iterator i = playersStore.begin(); i != playersStore.end(); ++i)
917 if (i->first != who)
918 i->second.plrPtr->GetSession()->SendPacket(data);
919}

References playersStore.

◆ SendToAllWatching()

void Channel::SendToAllWatching ( WorldPacket data)
private
928{
929 for (PlayersWatchingContainer::const_iterator i = playersWatchingStore.begin(); i != playersWatchingStore.end(); ++i)
930 (*i)->GetSession()->SendPacket(data);
931}

References playersWatchingStore.

Referenced by FlagsNotify(), JoinNotify(), and LeaveNotify().

◆ SendToOne()

void Channel::SendToOne ( WorldPacket data,
ObjectGuid  who 
)
private
922{
924 player->GetSession()->SendPacket(data);
925}
Player * FindConnectedPlayer(ObjectGuid const guid)
Definition ObjectAccessor.cpp:257

References ObjectAccessor::FindConnectedPlayer().

Referenced by Announce(), Invite(), JoinChannel(), KickOrBan(), LeaveChannel(), List(), Password(), Say(), SendWhoOwner(), SetMode(), SetOwner(), ToggleModeration(), and UnBan().

◆ SendWhoOwner()

void Channel::SendWhoOwner ( ObjectGuid  guid)
679{
680 WorldPacket data;
681 if (IsOn(guid))
682 MakeChannelOwner(&data);
683 else
684 MakeNotMember(&data);
685 SendToOne(&data, guid);
686}
void MakeChannelOwner(WorldPacket *data)
Definition Channel.cpp:1018

References IsOn(), MakeChannelOwner(), MakeNotMember(), and SendToOne().

◆ SetMode()

void Channel::SetMode ( Player const *  player,
std::string const &  p2n,
bool  mod,
bool  set 
)
573{
574 ObjectGuid guid = player->GetGUID();
575
576 if (!IsOn(guid))
577 {
578 WorldPacket data;
579 MakeNotMember(&data);
580 SendToOne(&data, guid);
581 return;
582 }
583
584 if (!playersStore[guid].IsModerator() && !player->GetSession()->IsGMAccount())
585 {
586 WorldPacket data;
587 MakeNotModerator(&data);
588 SendToOne(&data, guid);
589 return;
590 }
591
592 if (guid == _ownerGUID && std::string(p2n) == player->GetName() && mod)
593 return;
594
595 Player* newp = ObjectAccessor::FindPlayerByName(p2n, false);
596 ObjectGuid victim = newp ? newp->GetGUID() : ObjectGuid::Empty;
597
598 if (!victim || !IsOn(victim) ||
599 // allow make moderator from another team only if both is GMs
600 // at this moment this only way to show channel post for GM from another team
601 ((!player->GetSession()->IsGMAccount() || !newp->GetSession()->IsGMAccount()) && player->GetTeamId() != newp->GetTeamId() &&
603 {
604 WorldPacket data;
605 MakePlayerNotFound(&data, p2n);
606 SendToOne(&data, guid);
607 return;
608 }
609
610 if (_ownerGUID == victim && _ownerGUID != guid)
611 {
612 WorldPacket data;
613 MakeNotOwner(&data);
614 SendToOne(&data, guid);
615 return;
616 }
617
618 if (mod)
619 {
620 bool isBadConstantModerator = _channelRights.moderators.find(newp->GetSession()->GetAccountId()) != _channelRights.moderators.end();
621 if (!isBadConstantModerator)
622 SetModerator(newp->GetGUID(), set);
623 }
624 else
625 {
626 bool isGoodConstantModerator = _channelRights.moderators.find(player->GetSession()->GetAccountId()) != _channelRights.moderators.end();
627 if (!player->GetSession()->IsGMAccount() && !isGoodConstantModerator)
628 {
630 {
631 WorldPacket data;
632 MakeNotModerator(&data);
633 SendToOne(&data, guid);
634 return;
635 }
636 }
637
638 SetMute(newp->GetGUID(), set);
639 }
640}
@ CHANNEL_RIGHT_CANT_MUTE
Definition Channel.h:138
void SetMute(Player const *player, std::string const &newname)
Definition Channel.h:206
void SetModerator(Player const *player, std::string const &newname)
Definition Channel.h:204

References _channelRights, _ownerGUID, CHANNEL_RIGHT_CANT_MUTE, CONFIG_ALLOW_TWO_SIDE_INTERACTION_CHANNEL, ObjectGuid::Empty, ObjectAccessor::FindPlayerByName(), ChannelRights::flags, WorldSession::GetAccountId(), Object::GetGUID(), WorldObject::GetName(), Player::GetSession(), Player::GetTeamId(), WorldSession::IsGMAccount(), IsOn(), MakeNotMember(), MakeNotModerator(), MakeNotOwner(), MakePlayerNotFound(), ChannelRights::moderators, playersStore, SendToOne(), SetModerator(), SetMute(), and sWorld.

Referenced by SetModerator(), SetMute(), UnsetModerator(), and UnsetMute().

◆ SetModerator() [1/2]

void Channel::SetModerator ( ObjectGuid  guid,
bool  set 
)
inlineprivate
287 {
288 PlayerInfo& pinfo = playersStore[guid];
289 if (pinfo.IsModerator() != set)
290 {
291 uint8 oldFlag = pinfo.flags;
292 pinfo.SetModerator(set);
293
294 WorldPacket data;
295 MakeModeChange(&data, guid, oldFlag);
296 SendToAll(&data);
297
298 FlagsNotify(pinfo.plrPtr);
299 }
300 }
void MakeModeChange(WorldPacket *data, ObjectGuid guid, uint8 oldflags)
Definition Channel.cpp:1029

References Channel::PlayerInfo::flags, FlagsNotify(), Channel::PlayerInfo::IsModerator(), MakeModeChange(), playersStore, Channel::PlayerInfo::plrPtr, SendToAll(), and Channel::PlayerInfo::SetModerator().

◆ SetModerator() [2/2]

void Channel::SetModerator ( Player const *  player,
std::string const &  newname 
)
inline
204{ SetMode(player, newname, true, true); }
void SetMode(Player const *player, std::string const &p2n, bool mod, bool set)
Definition Channel.cpp:572

References SetMode().

Referenced by SetMode().

◆ SetMute() [1/2]

void Channel::SetMute ( ObjectGuid  guid,
bool  set 
)
inlineprivate
303 {
304 PlayerInfo& pinfo = playersStore[guid];
305 if (pinfo.IsMuted() != set)
306 {
307 uint8 oldFlag = pinfo.flags;
308 pinfo.SetMuted(set);
309
310 WorldPacket data;
311 MakeModeChange(&data, guid, oldFlag);
312 SendToAll(&data);
313 }
314 }

References Channel::PlayerInfo::flags, Channel::PlayerInfo::IsMuted(), MakeModeChange(), playersStore, SendToAll(), and Channel::PlayerInfo::SetMuted().

◆ SetMute() [2/2]

void Channel::SetMute ( Player const *  player,
std::string const &  newname 
)
inline
206{ SetMode(player, newname, false, true); }

References SetMode().

Referenced by SetMode().

◆ SetOwner() [1/2]

void Channel::SetOwner ( ObjectGuid  guid,
bool  exclaim = true 
)
864{
865 if (_ownerGUID)
866 {
867 // [] will re-add player after it possible removed
868 PlayerContainer::iterator p_itr = playersStore.find(_ownerGUID);
869 if (p_itr != playersStore.end())
870 {
871 p_itr->second.SetOwner(false);
872 FlagsNotify(p_itr->second.plrPtr);
873 }
874 }
875
876 _ownerGUID = guid;
877 if (_ownerGUID)
878 {
880
881 pinfo.SetModerator(true);
882 uint8 oldFlag = pinfo.flags;
883 pinfo.SetOwner(true);
884 FlagsNotify(pinfo.plrPtr);
885
887 if (player)
888 {
889 if (ShouldAnnouncePlayer(player))
890 {
891 WorldPacket data;
892
893 MakeModeChange(&data, _ownerGUID, oldFlag);
894 SendToAll(&data);
895
896 if (exclaim)
897 {
898 // MakeOwnerChanged will reset the packet for us
900 SendToAll(&data);
901 }
902 }
903 }
904 }
905}
void MakeOwnerChanged(WorldPacket *data, ObjectGuid guid)
Definition Channel.cpp:1001
Player * FindPlayer(ObjectGuid const guid)
Definition ObjectAccessor.cpp:245

References _ownerGUID, ObjectAccessor::FindPlayer(), Channel::PlayerInfo::flags, FlagsNotify(), MakeModeChange(), MakeOwnerChanged(), playersStore, Channel::PlayerInfo::plrPtr, SendToAll(), Channel::PlayerInfo::SetModerator(), Channel::PlayerInfo::SetOwner(), and ShouldAnnouncePlayer().

Referenced by JoinChannel(), KickOrBan(), LeaveChannel(), and SetOwner().

◆ SetOwner() [2/2]

void Channel::SetOwner ( Player const *  player,
std::string const &  name 
)
643{
644 ObjectGuid guid = player->GetGUID();
645
646 if (!IsOn(guid))
647 {
648 WorldPacket data;
649 MakeNotMember(&data);
650 SendToOne(&data, guid);
651 return;
652 }
653
654 bool isGoodConstantModerator = _channelRights.moderators.find(player->GetSession()->GetAccountId()) != _channelRights.moderators.end();
655 if (!player->GetSession()->IsGMAccount() && guid != _ownerGUID && !isGoodConstantModerator)
656 {
657 WorldPacket data;
658 MakeNotOwner(&data);
659 SendToOne(&data, guid);
660 return;
661 }
662
663 Player* newp = ObjectAccessor::FindPlayerByName(newname, false);
664 ObjectGuid victim = newp ? newp->GetGUID() : ObjectGuid::Empty;
665
666 if (!victim || !IsOn(victim) || (newp->GetTeamId() != player->GetTeamId() &&
668 {
669 WorldPacket data;
670 MakePlayerNotFound(&data, newname);
671 SendToOne(&data, guid);
672 return;
673 }
674
675 SetOwner(victim);
676}

References _channelRights, _ownerGUID, CONFIG_ALLOW_TWO_SIDE_INTERACTION_CHANNEL, ObjectGuid::Empty, ObjectAccessor::FindPlayerByName(), WorldSession::GetAccountId(), Object::GetGUID(), Player::GetSession(), Player::GetTeamId(), WorldSession::IsGMAccount(), IsOn(), MakeNotMember(), MakeNotOwner(), MakePlayerNotFound(), ChannelRights::moderators, SendToOne(), SetOwner(), and sWorld.

◆ SetPassword()

void Channel::SetPassword ( std::string const &  npassword)
inline
186{ _password = npassword; }

References _password.

Referenced by ChannelMgr::LoadChannels().

◆ ShouldAnnouncePlayer()

bool Channel::ShouldAnnouncePlayer ( Player const *  player) const
private
934{
935 return !(player->GetSession()->IsGMAccount() && sWorld->getBoolConfig(CONFIG_SILENTLY_GM_JOIN_TO_CHANNEL));
936}

References CONFIG_SILENTLY_GM_JOIN_TO_CHANNEL, Player::GetSession(), WorldSession::IsGMAccount(), and sWorld.

Referenced by JoinChannel(), KickOrBan(), LeaveChannel(), and SetOwner().

◆ ToggleModeration()

void Channel::ToggleModeration ( Player p)
1222{
1223 ObjectGuid guid = player->GetGUID();
1224
1225 if (!IsOn(guid))
1226 {
1227 WorldPacket data;
1228 MakeNotMember(&data);
1229 SendToOne(&data, guid);
1230 return;
1231 }
1232
1233 const uint32 level = sWorld->getIntConfig(CONFIG_GM_LEVEL_CHANNEL_MODERATION);
1234 const bool gm = (level && player->GetSession()->GetSecurity() >= level);
1235
1236 if (!playersStore[guid].IsModerator() && !gm)
1237 {
1238 WorldPacket data;
1239 MakeNotModerator(&data);
1240 SendToOne(&data, guid);
1241 return;
1242 }
1243
1244 // toggle channel moderation
1246
1247 WorldPacket data;
1248 if (_moderation)
1249 {
1250 MakeModerationOn(&data, guid);
1251 }
1252 else
1253 {
1254 MakeModerationOff(&data, guid);
1255 }
1256
1257 SendToAll(&data);
1258}
@ CONFIG_GM_LEVEL_CHANNEL_MODERATION
Definition IWorld.h:413
bool _moderation
Definition Channel.h:321
void MakeModerationOn(WorldPacket *data, ObjectGuid guid)
Definition Channel.cpp:1260
void MakeModerationOff(WorldPacket *data, ObjectGuid guid)
Definition Channel.cpp:1266

References _moderation, CONFIG_GM_LEVEL_CHANNEL_MODERATION, Object::GetGUID(), WorldSession::GetSecurity(), Player::GetSession(), IsOn(), MakeModerationOff(), MakeModerationOn(), MakeNotMember(), MakeNotModerator(), playersStore, SendToAll(), SendToOne(), and sWorld.

◆ UnBan() [1/2]

void Channel::UnBan ( ObjectGuid  guid)
527{
528 if (!IsBanned(guid))
529 return;
530 bannedStore.erase(guid);
532}
void RemoveChannelBanFromDB(ObjectGuid guid) const
Definition Channel.cpp:132

References bannedStore, IsBanned(), and RemoveChannelBanFromDB().

◆ UnBan() [2/2]

void Channel::UnBan ( Player const *  player,
std::string const &  badname 
)
468{
469 ObjectGuid good = player->GetGUID();
470
471 if (!IsOn(good))
472 {
473 WorldPacket data;
474 MakeNotMember(&data);
475 SendToOne(&data, good);
476 return;
477 }
478
479 if (!playersStore[good].IsModerator() && !player->GetSession()->IsGMAccount())
480 {
481 WorldPacket data;
482 MakeNotModerator(&data);
483 SendToOne(&data, good);
484 return;
485 }
486
487 ObjectGuid victim;
488 if (ObjectGuid guid = sCharacterCache->GetCharacterGuidByName(badname))
489 {
490 victim = guid;
491 }
492
493 if (!victim || !IsBanned(victim))
494 {
495 WorldPacket data;
496 MakePlayerNotFound(&data, badname);
497 SendToOne(&data, good);
498 return;
499 }
500
501 bool isConstantModerator = _channelRights.moderators.find(player->GetSession()->GetAccountId()) != _channelRights.moderators.end();
502 if (!player->GetSession()->IsGMAccount() && !isConstantModerator)
503 {
505 {
506 WorldPacket data;
507 MakeNotModerator(&data);
508 SendToOne(&data, good);
509 return;
510 }
511 }
512
514 LOG_GM(player->GetSession()->GetAccountId(), "Command: /unban {} {} (Moderator {} [{}, account: {}] unbanned {} [{}])",
515 GetName(), badname, player->GetName(), player->GetGUID().ToString(), player->GetSession()->GetAccountId(),
516 badname, victim.ToString());
517
518 bannedStore.erase(victim);
520
521 WorldPacket data;
522 MakePlayerUnbanned(&data, victim, good);
523 SendToAll(&data);
524}
#define LOG_GM(accountId__,...)
Definition Log.h:176
void MakePlayerUnbanned(WorldPacket *data, ObjectGuid bad, ObjectGuid good)
Definition Channel.cpp:1073
std::string ToString() const
Definition ObjectGuid.cpp:47

References _channelRights, bannedStore, CHANNEL_RIGHT_CANT_BAN, ChannelRights::flags, WorldSession::GetAccountId(), Object::GetGUID(), GetName(), WorldObject::GetName(), Player::GetSession(), IsBanned(), WorldSession::IsGMAccount(), IsOn(), LOG_GM, MakeNotMember(), MakeNotModerator(), MakePlayerNotFound(), MakePlayerUnbanned(), ChannelRights::moderators, playersStore, RemoveChannelBanFromDB(), sCharacterCache, SendToAll(), SendToOne(), and ObjectGuid::ToString().

◆ UnsetModerator()

void Channel::UnsetModerator ( Player const *  player,
std::string const &  newname 
)
inline
205{ SetMode(player, newname, true, false); }

References SetMode().

◆ UnsetMute()

void Channel::UnsetMute ( Player const *  player,
std::string const &  newname 
)
inline
207{ SetMode(player, newname, false, false); }

References SetMode().

◆ UpdateChannelInDB()

void Channel::UpdateChannelInDB ( ) const
private
103{
104 if (_IsSaved)
105 {
107 stmt->SetData(0, _announce);
108 stmt->SetData(1, _password);
109 stmt->SetData(2, _channelDBId);
110 CharacterDatabase.Execute(stmt);
111
112 LOG_DEBUG("chat.system", "Channel({}) updated in database", _name);
113 }
114}
@ CHAR_UPD_CHANNEL
Definition CharacterDatabase.h:184

References _announce, _channelDBId, _IsSaved, _name, _password, CHAR_UPD_CHANNEL, CharacterDatabase, LOG_DEBUG, and PreparedStatementBase::SetData().

Referenced by Announce(), and Password().

◆ UpdateChannelUseageInDB()

void Channel::UpdateChannelUseageInDB ( ) const
private
117{
119 stmt->SetData(0, _channelDBId);
120 CharacterDatabase.Execute(stmt);
121}
@ CHAR_UPD_CHANNEL_USAGE
Definition CharacterDatabase.h:186

References _channelDBId, CHAR_UPD_CHANNEL_USAGE, CharacterDatabase, and PreparedStatementBase::SetData().

Referenced by JoinChannel(), and LeaveChannel().

◆ Voice()

void Channel::Voice ( ObjectGuid  guid1,
ObjectGuid  guid2 
)
939{
940}

Member Data Documentation

◆ _announce

bool Channel::_announce
private

◆ _channelDBId

◆ _channelId

uint32 Channel::_channelId
private

Referenced by GetChannelId(), and IsConstant().

◆ _channelRights

◆ _flags

uint8 Channel::_flags
private

Referenced by Channel(), GetFlags(), and HasFlag().

◆ _isOwnerGM

bool Channel::_isOwnerGM
private

Referenced by JoinChannel(), and LeaveChannel().

◆ _IsSaved

bool Channel::_IsSaved
private

Referenced by Channel(), and UpdateChannelInDB().

◆ _moderation

bool Channel::_moderation
private

Referenced by ToggleModeration().

◆ _name

std::string Channel::_name
private

◆ _ownerGUID

ObjectGuid Channel::_ownerGUID
private

◆ _ownership

bool Channel::_ownership
private

◆ _password

std::string Channel::_password
private

◆ _teamId

TeamId Channel::_teamId
private

Referenced by Channel().

◆ bannedStore

BannedContainer Channel::bannedStore
private

Referenced by AddBan(), IsBanned(), KickOrBan(), UnBan(), and UnBan().

◆ playersStore

◆ playersWatchingStore

PlayersWatchingContainer Channel::playersWatchingStore
private

The documentation for this class was generated from the following files: