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 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}
DatabaseWorkerPool< CharacterDatabaseConnection > CharacterDatabase
Accessor to the character database.
Definition: DatabaseEnv.cpp:21
@ CHAR_INS_CHANNEL
Definition: CharacterDatabase.h:183
@ CHANNEL_FLAG_TRADE
Definition: Channel.h:81
@ CHANNEL_FLAG_NOT_LFG
Definition: Channel.h:82
@ CHANNEL_FLAG_GENERAL
Definition: Channel.h:83
@ CHANNEL_FLAG_CUSTOM
Definition: Channel.h:79
@ CHANNEL_FLAG_LFG
Definition: Channel.h:85
@ CHANNEL_FLAG_CITY
Definition: Channel.h:84
@ CHANNEL_DBC_FLAG_TRADE
Definition: Channel.h:100
@ CHANNEL_DBC_FLAG_CITY_ONLY2
Definition: Channel.h:102
@ CHANNEL_DBC_FLAG_LFG
Definition: Channel.h:105
@ CHANNEL_RIGHT_FORCE_NO_ANNOUNCEMENTS
Definition: Channel.h:136
@ CHANNEL_RIGHT_DONT_PRESERVE
Definition: Channel.h:144
@ CHANNEL_RIGHT_FORCE_ANNOUNCEMENTS
Definition: Channel.h:137
@ CHANNEL_RIGHT_NO_OWNERSHIP
Definition: Channel.h:138
DBCStorage< ChatChannelsEntry > sChatChannelsStore(ChatChannelsEntryfmt)
@ CONFIG_PRESERVE_CUSTOM_CHANNELS
Definition: IWorld.h:141
#define sWorld
Definition: World.h:451
Definition: PreparedStatement.h:158
Acore::Types::is_default< T > SetData(const uint8 index, T value)
Definition: PreparedStatement.h:78
uint32 flags
Definition: Channel.h:127
uint32 _channelId
Definition: Channel.h:328
bool _isOwnerGM
Definition: Channel.h:326
ChannelRights _channelRights
Definition: Channel.h:334
bool _announce
Definition: Channel.h:322
uint8 _flags
Definition: Channel.h:327
bool _ownership
Definition: Channel.h:324
std::string _password
Definition: Channel.h:333
uint32 _channelDBId
Definition: Channel.h:329
TeamId _teamId
Definition: Channel.h:330
std::string _name
Definition: Channel.h:332
bool _IsSaved
Definition: Channel.h:325
static uint32 _channelIdMax
Definition: ChannelMgr.h:49
static const ChannelRights & GetChannelRightsFor(const std::string &name)
Definition: ChannelMgr.cpp:208
Definition: DBCStructure.h:643

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
200{ bannedStore[guid] = time; }
BannedContainer bannedStore
Definition: Channel.h:336

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:147

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

Referenced by KickOrBan().

◆ AddWatching()

void Channel::AddWatching ( Player p)
1222{
1223 if (!IsOn(p->GetGUID()))
1224 return;
1225 playersWatchingStore.insert(p);
1226}
PlayersWatchingContainer playersWatchingStore
Definition: Channel.h:337
bool IsOn(ObjectGuid who) const
Definition: Channel.h:274
static ObjectGuid GetGUID(Object const *o)
Definition: Object.h:106

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

◆ Announce()

void Channel::Announce ( Player const *  player)
738{
739 ObjectGuid guid = player->GetGUID();
740 uint32 sec = player->GetSession()->GetSecurity();
741
742 if (!IsOn(guid))
743 {
744 WorldPacket data;
745 MakeNotMember(&data);
746 SendToOne(&data, guid);
747 return;
748 }
749
750 if (!playersStore[guid].IsModerator() && !AccountMgr::IsGMAccount(sec))
751 {
752 WorldPacket data;
753 MakeNotModerator(&data);
754 SendToOne(&data, guid);
755 return;
756 }
757
759 {
760 WorldPacket data;
761 MakeNotModerator(&data);
762 SendToOne(&data, guid);
763 return;
764 }
765
767
768 WorldPacket data;
769 if (_announce)
770 MakeAnnouncementsOn(&data, guid);
771 else
772 MakeAnnouncementsOff(&data, guid);
773 SendToAll(&data);
774
776}
std::uint32_t uint32
Definition: Define.h:108
bool IsGMAccount(uint32 gmlevel)
Definition: AccountMgr.cpp:281
void MakeNotMember(WorldPacket *data)
Definition: Channel.cpp:999
void MakeAnnouncementsOn(WorldPacket *data, ObjectGuid guid)
Definition: Channel.cpp:1051
void SendToOne(WorldPacket *data, ObjectGuid who)
Definition: Channel.cpp:940
void UpdateChannelInDB() const
Definition: Channel.cpp:102
PlayerContainer playersStore
Definition: Channel.h:335
void MakeNotModerator(WorldPacket *data)
Definition: Channel.cpp:1004
void MakeAnnouncementsOff(WorldPacket *data, ObjectGuid guid)
Definition: Channel.cpp:1057
void SendToAll(WorldPacket *data, ObjectGuid guid=ObjectGuid::Empty)
Definition: Channel.cpp:926
Definition: ObjectGuid.h:120
Definition: WorldPacket.h:27

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

◆ Ban()

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

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}
constexpr auto DAY
Definition: Common.h:58
SQLTransaction< CharacterDatabaseConnection > CharacterDatabaseTransaction
Definition: DatabaseEnvFwd.h:70
@ CHAR_DEL_OLD_CHANNELS_BANS
Definition: CharacterDatabase.h:188
@ CHAR_DEL_OLD_CHANNELS
Definition: CharacterDatabase.h:187
@ CONFIG_PRESERVE_CUSTOM_CHANNEL_DURATION
Definition: IWorld.h:356

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 
)
957{
958}

◆ FlagsNotify()

void Channel::FlagsNotify ( Player p)
1205{
1207 return;
1209 return;
1210
1211 WorldPacket data(SMSG_USERLIST_UPDATE, 8 + 1 + 1 + 4 + GetName().size());
1212 data << p->GetGUID();
1213 data << uint8(GetPlayerFlags(p->GetGUID()));
1214 data << uint8(GetFlags());
1215 data << uint32(GetNumPlayers());
1216 data << GetName();
1217
1218 SendToAllWatching(&data);
1219}
std::uint8_t uint8
Definition: Define.h:110
@ CHANNEL_RIGHT_CANT_SPEAK
Definition: Channel.h:139
@ SMSG_USERLIST_UPDATE
Definition: Opcodes.h:1040
bool IsPlayerAccount(uint32 gmlevel)
Definition: AccountMgr.cpp:276
void SendToAllWatching(WorldPacket *data)
Definition: Channel.cpp:946
std::string const & GetName() const
Definition: Channel.h:183
uint8 GetPlayerFlags(ObjectGuid guid) const
Definition: Channel.h:282
uint32 GetNumPlayers() const
Definition: Channel.h:191
uint8 GetFlags() const
Definition: Channel.h:192
WorldSession * GetSession() const
Definition: Player.h:1948
AccountTypes GetSecurity() const
Definition: WorldSession.h:358

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
185{ return _channelDBId; }

References _channelDBId.

◆ GetChannelId()

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

References _channelId.

Referenced by MakeYouJoined(), and MakeYouLeft().

◆ GetFlags()

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

References _flags.

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

◆ GetName()

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

◆ GetNumPlayers()

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

References playersStore.

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

◆ GetPassword()

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

References _password.

◆ GetPlayerFlags()

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

References playersStore.

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

◆ HasFlag()

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

References _flags.

Referenced by JoinChannel(), and ChatLogScript::OnChat().

◆ Invite()

void Channel::Invite ( Player const *  player,
std::string const &  newp 
)
820{
821 ObjectGuid guid = player->GetGUID();
822
823 if (!IsOn(guid))
824 {
825 WorldPacket data;
826 MakeNotMember(&data);
827 SendToOne(&data, guid);
828 return;
829 }
830
831 Player* newp = ObjectAccessor::FindPlayerByName(newname, false);
832 if (!newp || !newp->isGMVisible())
833 {
834 WorldPacket data;
835 MakePlayerNotFound(&data, newname);
836 SendToOne(&data, guid);
837 return;
838 }
839
840 if (IsBanned(newp->GetGUID()))
841 {
842 WorldPacket data;
843 MakePlayerInviteBanned(&data, newname);
844 SendToOne(&data, guid);
845 return;
846 }
847
848 if (newp->GetTeamId() != player->GetTeamId())
849 {
850 WorldPacket data;
852 SendToOne(&data, guid);
853 return;
854 }
855
856 if (IsOn(newp->GetGUID()))
857 {
858 WorldPacket data;
859 MakePlayerAlreadyMember(&data, newp->GetGUID());
860 SendToOne(&data, guid);
861 return;
862 }
863
864 if (!newp->GetSocial()->HasIgnore(guid))
865 {
866 WorldPacket data;
867 MakeInvite(&data, guid);
868 SendToOne(&data, newp->GetGUID());
869 data.clear();
870 }
871
872 WorldPacket data;
873 MakePlayerInvited(&data, newp->GetName());
874 SendToOne(&data, guid);
875}
Player * FindPlayerByName(std::string const &name, bool checkInWorld=true)
Definition: ObjectAccessor.cpp:276
void MakePlayerNotFound(WorldPacket *data, std::string const &name)
Definition: Channel.cpp:1021
void MakePlayerInvited(WorldPacket *data, std::string const &name)
Definition: Channel.cpp:1132
void MakePlayerInviteBanned(WorldPacket *data, std::string const &name)
Definition: Channel.cpp:1138
void MakeInviteWrongFaction(WorldPacket *data)
Definition: Channel.cpp:1112
void MakeInvite(WorldPacket *data, ObjectGuid guid)
Definition: Channel.cpp:1106
void MakePlayerAlreadyMember(WorldPacket *data, ObjectGuid guid)
Definition: Channel.cpp:1100
bool IsBanned(ObjectGuid guid) const
Definition: Channel.cpp:96
std::string const & GetName() const
Definition: Object.h:446
Definition: Player.h:1046
bool isGMVisible() const
Definition: Player.h:1142
TeamId GetTeamId(bool original=false) const
Definition: Player.h:2059
PlayerSocial * GetSocial()
Definition: Player.h:1121
bool HasIgnore(ObjectGuid ignore_guid) const
Definition: SocialMgr.cpp:193
void clear()
Definition: ByteBuffer.h:122

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
187{ 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(), and UnBan().

◆ IsConstant()

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

References _channelId.

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

◆ IsLFG()

bool Channel::IsLFG ( ) const
inline
188{ return GetFlags() & CHANNEL_FLAG_LFG; }

References CHANNEL_FLAG_LFG, and GetFlags().

◆ 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
189 sWorld->getBoolConfig(CONFIG_RESTRICTED_LFG_CHANNEL) &&
191 player->GetGroup())
192 {
193 WorldPacket data;
194 MakeNotInLfg(&data);
195 SendToOne(&data, guid);
196 return;
197 }
198
199 player->JoinedChannel(this);
200
203 {
204 WorldPacket data;
205 MakeJoined(&data, guid);
206 SendToAll(&data);
207 }
208
209 PlayerInfo pinfo;
210 pinfo.player = guid;
211 pinfo.flags = MEMBER_FLAG_NONE;
212 pinfo.plrPtr = player;
213
214 playersStore[guid] = pinfo;
215
216 if (_channelRights.joinMessage.length())
218
219 WorldPacket data;
220 MakeYouJoined(&data);
221 SendToOne(&data, guid);
222
223 JoinNotify(player);
224
225 playersStore[guid].SetOwnerGM(AccountMgr::IsGMAccount(player->GetSession()->GetSecurity()));
226
227 // Custom channel handling
228 if (!IsConstant())
229 {
230 // Update last_used timestamp in db
231 if (!playersStore.empty())
233
235 {
236 playersStore[guid].SetModerator(true);
237 FlagsNotify(player);
238 }
239
240 // If the channel has no owner yet and ownership is allowed, set the new owner.
241 // If the channel owner is a GM and the config SilentGMJoinChannel is enabled, set the new owner
243 {
244 _isOwnerGM = playersStore[guid].IsOwnerGM();
245 SetOwner(guid, false);
246 }
247
249 playersStore[guid].SetMuted(true);
250 }
251}
@ MEMBER_FLAG_NONE
Definition: Channel.h:111
@ CONFIG_SILENTLY_GM_JOIN_TO_CHANNEL
Definition: IWorld.h:103
@ CONFIG_RESTRICTED_LFG_CHANNEL
Definition: IWorld.h:102
std::set< uint32 > moderators
Definition: Channel.h:131
std::string joinMessage
Definition: Channel.h:129
bool IsConstant() const
Definition: Channel.h:186
void MakeJoined(WorldPacket *data, ObjectGuid guid)
Definition: Channel.cpp:967
void JoinNotify(Player *p)
Definition: Channel.cpp:1171
bool HasFlag(uint8 flag) const
Definition: Channel.h:193
ObjectGuid _ownerGUID
Definition: Channel.h:331
void SetOwner(ObjectGuid guid, bool exclaim=true)
Definition: Channel.cpp:877
void MakeYouJoined(WorldPacket *data)
Definition: Channel.cpp:979
void MakeNotInLfg(WorldPacket *data)
Definition: Channel.cpp:1154
void MakeBanned(WorldPacket *data)
Definition: Channel.cpp:1075
void MakeWrongPassword(WorldPacket *data)
Definition: Channel.cpp:994
void UpdateChannelUseageInDB() const
Definition: Channel.cpp:116
void FlagsNotify(Player *p)
Definition: Channel.cpp:1204
Definition: Chat.h:38
void PSendSysMessage(char const *fmt, Args &&... args)
Definition: Chat.h:60
Definition: Player.h:336
Group * GetGroup()
Definition: Player.h:2418
void JoinedChannel(Channel *c)
Definition: Player.cpp:4894
uint32 GetAccountId() const
Definition: WorldSession.h:360

References _announce, _channelRights, _isOwnerGM, _ownerGUID, _ownership, _password, CHANNEL_FLAG_LFG, CHANNEL_RIGHT_CANT_SPEAK, CONFIG_RESTRICTED_LFG_CHANNEL, CONFIG_SILENTLY_GM_JOIN_TO_CHANNEL, ChannelRights::flags, Channel::PlayerInfo::flags, FlagsNotify(), WorldSession::GetAccountId(), Player::GetGroup(), Object::GetGUID(), WorldSession::GetSecurity(), Player::GetSession(), HasFlag(), IsBanned(), IsConstant(), AccountMgr::IsGMAccount(), IsOn(), AccountMgr::IsPlayerAccount(), 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(), sWorld, and UpdateChannelUseageInDB().

Referenced by Player::UpdateLocalChannels().

◆ JoinNotify()

void Channel::JoinNotify ( Player p)
1172{
1174 return;
1176 return;
1177
1178 WorldPacket data(SMSG_USERLIST_ADD, 8 + 1 + 1 + 4 + GetName().size());
1179 data << p->GetGUID();
1180 data << uint8(GetPlayerFlags(p->GetGUID()));
1181 data << uint8(GetFlags());
1182 data << uint32(GetNumPlayers());
1183 data << GetName();
1184
1185 SendToAllWatching(&data);
1186}
@ 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
198{ KickOrBan(player, badname, false); }

References KickOrBan().

◆ KickOrBan()

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

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

Referenced by Ban(), and Kick().

◆ LeaveChannel()

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

References _announce, _isOwnerGM, _ownership, ByteBuffer::clear(), CONFIG_SILENTLY_GM_JOIN_TO_CHANNEL, ObjectGuid::Empty, Object::GetGUID(), WorldSession::GetSecurity(), Player::GetSession(), IsConstant(), AccountMgr::IsGMAccount(), IsOn(), LeaveNotify(), Player::LeftChannel(), MakeLeft(), MakeNotMember(), MakeYouLeft(), playersStore, RemoveWatching(), SendToAll(), SendToOne(), SetOwner(), sWorld, and UpdateChannelUseageInDB().

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

◆ LeaveNotify()

void Channel::LeaveNotify ( Player p)
1189{
1191 return;
1193 return;
1194
1195 WorldPacket data(SMSG_USERLIST_REMOVE, 8 + 1 + 4 + GetName().size());
1196 data << p->GetGUID();
1197 data << uint8(GetFlags());
1198 data << uint32(GetNumPlayers());
1199 data << GetName();
1200
1201 SendToAllWatching(&data);
1202}
@ 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)
702{
703 ObjectGuid guid = player->GetGUID();
704
705 if (!IsOn(guid))
706 {
707 WorldPacket data;
708 MakeNotMember(&data);
709 SendToOne(&data, guid);
710 return;
711 }
712
713 LOG_DEBUG("chat.system", "SMSG_CHANNEL_LIST {} Channel: {}", player->GetSession()->GetPlayerInfo(), GetName());
714 WorldPacket data(SMSG_CHANNEL_LIST, 1 + (GetName().size() + 1) + 1 + 4 + playersStore.size() * (8 + 1));
715 data << uint8(1); // channel type?
716 data << GetName(); // channel name
717 data << uint8(GetFlags()); // channel flags?
718
719 size_t pos = data.wpos();
720 data << uint32(0); // size of list, placeholder
721
722 uint32 count = 0;
724 for (PlayerContainer::const_iterator i = playersStore.begin(); i != playersStore.end(); ++i)
725 if (AccountMgr::IsPlayerAccount(i->second.plrPtr->GetSession()->GetSecurity()))
726 {
727 data << i->first;
728 data << uint8(i->second.flags); // flags seems to be changed...
729 ++count;
730 }
731
732 data.put<uint32>(pos, count);
733
734 SendToOne(&data, guid);
735}
#define LOG_DEBUG(filterType__,...)
Definition: Log.h:171
@ 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
1058{
1060 *data << guid;
1061}
@ CHAT_ANNOUNCEMENTS_OFF_NOTICE
Definition: Channel.h:52
void MakeNotifyPacket(WorldPacket *data, uint8 notify_type)
Definition: Channel.cpp:960

References CHAT_ANNOUNCEMENTS_OFF_NOTICE, and MakeNotifyPacket().

Referenced by Announce().

◆ MakeAnnouncementsOn()

void Channel::MakeAnnouncementsOn ( WorldPacket data,
ObjectGuid  guid 
)
private
1052{
1054 *data << guid;
1055}
@ CHAT_ANNOUNCEMENTS_ON_NOTICE
Definition: Channel.h:51

References CHAT_ANNOUNCEMENTS_ON_NOTICE, and MakeNotifyPacket().

Referenced by Announce().

◆ MakeBanned()

void Channel::MakeBanned ( WorldPacket data)
private
1076{
1078}
@ CHAT_BANNED_NOTICE
Definition: Channel.h:57

References CHAT_BANNED_NOTICE, and MakeNotifyPacket().

Referenced by JoinChannel().

◆ MakeChannelOwner()

void Channel::MakeChannelOwner ( WorldPacket data)
private
1033{
1034 std::string name = "";
1035
1036 if (!sCharacterCache->GetCharacterNameByGuid(_ownerGUID, name) || name.empty())
1037 name = "PLAYER_NOT_FOUND";
1038
1040 *data << ((IsConstant() || !_ownerGUID) ? "Nobody" : name);
1041}
@ CHAT_CHANNEL_OWNER_NOTICE
Definition: Channel.h:49

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

Referenced by SendWhoOwner().

◆ MakeInvalidName()

void Channel::MakeInvalidName ( WorldPacket data)
private
1123{
1125}
@ CHAT_INVALID_NAME_NOTICE
Definition: Channel.h:65

References CHAT_INVALID_NAME_NOTICE, and MakeNotifyPacket().

◆ MakeInvite()

void Channel::MakeInvite ( WorldPacket data,
ObjectGuid  guid 
)
private
1107{
1109 *data << guid;
1110}
@ CHAT_INVITE_NOTICE
Definition: Channel.h:62

References CHAT_INVITE_NOTICE, and MakeNotifyPacket().

Referenced by Invite().

◆ MakeInviteWrongFaction()

void Channel::MakeInviteWrongFaction ( WorldPacket data)
private
1113{
1115}
@ CHAT_INVITE_WRONG_FACTION_NOTICE
Definition: Channel.h:63

References CHAT_INVITE_WRONG_FACTION_NOTICE, and MakeNotifyPacket().

Referenced by Invite().

◆ MakeJoined()

void Channel::MakeJoined ( WorldPacket data,
ObjectGuid  guid 
)
private
968{
970 *data << guid;
971}
@ CHAT_JOINED_NOTICE
Definition: Channel.h:36

References CHAT_JOINED_NOTICE, and MakeNotifyPacket().

Referenced by JoinChannel().

◆ MakeLeft()

void Channel::MakeLeft ( WorldPacket data,
ObjectGuid  guid 
)
private
974{
976 *data << guid;
977}
@ CHAT_LEFT_NOTICE
Definition: Channel.h:37

References CHAT_LEFT_NOTICE, and MakeNotifyPacket().

Referenced by LeaveChannel().

◆ MakeModeChange()

void Channel::MakeModeChange ( WorldPacket data,
ObjectGuid  guid,
uint8  oldflags 
)
private
1044{
1046 *data << guid;
1047 *data << uint8(oldflags);
1048 *data << uint8(GetPlayerFlags(guid));
1049}
@ CHAT_MODE_CHANGE_NOTICE
Definition: Channel.h:50

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

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

◆ MakeModerationOff()

void Channel::MakeModerationOff ( WorldPacket data,
ObjectGuid  guid 
)
private
1281{
1283 *data << guid;
1284}
@ CHAT_MODERATION_OFF_NOTICE
Definition: Channel.h:54

References CHAT_MODERATION_OFF_NOTICE, and MakeNotifyPacket().

Referenced by ToggleModeration().

◆ MakeModerationOn()

void Channel::MakeModerationOn ( WorldPacket data,
ObjectGuid  guid 
)
private
1275{
1277 *data << guid;
1278}
@ CHAT_MODERATION_ON_NOTICE
Definition: Channel.h:53

References CHAT_MODERATION_ON_NOTICE, and MakeNotifyPacket().

Referenced by ToggleModeration().

◆ MakeMuted()

void Channel::MakeMuted ( WorldPacket data)
private
1064{
1066}
@ CHAT_MUTED_NOTICE
Definition: Channel.h:55

References CHAT_MUTED_NOTICE, and MakeNotifyPacket().

Referenced by Say().

◆ MakeNotifyPacket()

◆ MakeNotInArea()

void Channel::MakeNotInArea ( WorldPacket data)
private
1150{
1152}
@ CHAT_NOT_IN_AREA_NOTICE
Definition: Channel.h:70

References CHAT_NOT_IN_AREA_NOTICE, and MakeNotifyPacket().

◆ MakeNotInLfg()

void Channel::MakeNotInLfg ( WorldPacket data)
private
1155{
1157}
@ CHAT_NOT_IN_LFG_NOTICE
Definition: Channel.h:71

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
1128{
1130}
@ CHAT_NOT_MODERATED_NOTICE
Definition: Channel.h:66

References CHAT_NOT_MODERATED_NOTICE, and MakeNotifyPacket().

◆ MakeNotModerator()

void Channel::MakeNotModerator ( WorldPacket data)
private
1005{
1007}
@ CHAT_NOT_MODERATOR_NOTICE
Definition: Channel.h:44

References CHAT_NOT_MODERATOR_NOTICE, and MakeNotifyPacket().

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

◆ MakeNotOwner()

void Channel::MakeNotOwner ( WorldPacket data)
private
1028{
1030}
@ CHAT_NOT_OWNER_NOTICE
Definition: Channel.h:48

References CHAT_NOT_OWNER_NOTICE, and MakeNotifyPacket().

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

◆ MakeOwnerChanged()

void Channel::MakeOwnerChanged ( WorldPacket data,
ObjectGuid  guid 
)
private
1016{
1018 *data << guid;
1019}
@ CHAT_OWNER_CHANGED_NOTICE
Definition: Channel.h:46

References CHAT_OWNER_CHANGED_NOTICE, and MakeNotifyPacket().

Referenced by SetOwner().

◆ MakePasswordChanged()

void Channel::MakePasswordChanged ( WorldPacket data,
ObjectGuid  guid 
)
private
1010{
1012 *data << guid;
1013}
@ CHAT_PASSWORD_CHANGED_NOTICE
Definition: Channel.h:45

References CHAT_PASSWORD_CHANGED_NOTICE, and MakeNotifyPacket().

Referenced by Password().

◆ MakePlayerAlreadyMember()

void Channel::MakePlayerAlreadyMember ( WorldPacket data,
ObjectGuid  guid 
)
private
1101{
1103 *data << guid;
1104}
@ CHAT_PLAYER_ALREADY_MEMBER_NOTICE
Definition: Channel.h:61

References CHAT_PLAYER_ALREADY_MEMBER_NOTICE, and MakeNotifyPacket().

Referenced by Invite(), and JoinChannel().

◆ MakePlayerBanned()

void Channel::MakePlayerBanned ( WorldPacket data,
ObjectGuid  bad,
ObjectGuid  good 
)
private
1081{
1083 *data << bad;
1084 *data << good;
1085}
@ CHAT_PLAYER_BANNED_NOTICE
Definition: Channel.h:58

References CHAT_PLAYER_BANNED_NOTICE, and MakeNotifyPacket().

Referenced by KickOrBan().

◆ MakePlayerInviteBanned()

void Channel::MakePlayerInviteBanned ( WorldPacket data,
std::string const &  name 
)
private
1139{
1141 *data << name;
1142}
@ CHAT_PLAYER_INVITE_BANNED_NOTICE
Definition: Channel.h:68

References CHAT_PLAYER_INVITE_BANNED_NOTICE, and MakeNotifyPacket().

Referenced by Invite().

◆ MakePlayerInvited()

void Channel::MakePlayerInvited ( WorldPacket data,
std::string const &  name 
)
private
1133{
1135 *data << name;
1136}
@ CHAT_PLAYER_INVITED_NOTICE
Definition: Channel.h:67

References CHAT_PLAYER_INVITED_NOTICE, and MakeNotifyPacket().

Referenced by Invite().

◆ MakePlayerKicked()

void Channel::MakePlayerKicked ( WorldPacket data,
ObjectGuid  bad,
ObjectGuid  good 
)
private
1069{
1071 *data << bad;
1072 *data << good;
1073}
@ CHAT_PLAYER_KICKED_NOTICE
Definition: Channel.h:56

References CHAT_PLAYER_KICKED_NOTICE, and MakeNotifyPacket().

Referenced by KickOrBan().

◆ MakePlayerNotBanned()

void Channel::MakePlayerNotBanned ( WorldPacket data,
std::string const &  name 
)
private
1095{
1097 *data << name;
1098}
@ CHAT_PLAYER_NOT_BANNED_NOTICE
Definition: Channel.h:60

References CHAT_PLAYER_NOT_BANNED_NOTICE, and MakeNotifyPacket().

◆ MakePlayerNotFound()

void Channel::MakePlayerNotFound ( WorldPacket data,
std::string const &  name 
)
private
1022{
1024 *data << name;
1025}
@ CHAT_PLAYER_NOT_FOUND_NOTICE
Definition: Channel.h:47

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
1088{
1090 *data << bad;
1091 *data << good;
1092}
@ CHAT_PLAYER_UNBANNED_NOTICE
Definition: Channel.h:59

References CHAT_PLAYER_UNBANNED_NOTICE, and MakeNotifyPacket().

Referenced by UnBan().

◆ MakeThrottled()

void Channel::MakeThrottled ( WorldPacket data)
private
1145{
1147}
@ CHAT_THROTTLED_NOTICE
Definition: Channel.h:69

References CHAT_THROTTLED_NOTICE, and MakeNotifyPacket().

◆ MakeVoiceOff()

void Channel::MakeVoiceOff ( WorldPacket data,
ObjectGuid  guid 
)
private
1166{
1168 *data << guid;
1169}
@ CHAT_VOICE_OFF_NOTICE
Definition: Channel.h:73

References CHAT_VOICE_OFF_NOTICE, and MakeNotifyPacket().

◆ MakeVoiceOn()

void Channel::MakeVoiceOn ( WorldPacket data,
ObjectGuid  guid 
)
private
1160{
1162 *data << guid;
1163}
@ CHAT_VOICE_ON_NOTICE
Definition: Channel.h:72

References CHAT_VOICE_ON_NOTICE, and MakeNotifyPacket().

◆ MakeWrongFaction()

void Channel::MakeWrongFaction ( WorldPacket data)
private
1118{
1120}
@ CHAT_WRONG_FACTION_NOTICE
Definition: Channel.h:64

References CHAT_WRONG_FACTION_NOTICE, and MakeNotifyPacket().

◆ MakeWrongPassword()

void Channel::MakeWrongPassword ( WorldPacket data)
private
995{
997}
@ CHAT_WRONG_PASSWORD_NOTICE
Definition: Channel.h:42

References CHAT_WRONG_PASSWORD_NOTICE, and MakeNotifyPacket().

Referenced by JoinChannel().

◆ MakeYouJoined()

void Channel::MakeYouJoined ( WorldPacket data)
private
980{
982 *data << uint8(GetFlags());
983 *data << uint32(GetChannelId());
984 *data << uint32(0);
985}
@ CHAT_YOU_JOINED_NOTICE
Definition: Channel.h:39
uint32 GetChannelId() const
Definition: Channel.h:184

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

Referenced by JoinChannel().

◆ MakeYouLeft()

void Channel::MakeYouLeft ( WorldPacket data)
private
988{
990 *data << uint32(GetChannelId());
991 *data << uint8(IsConstant());
992}
@ CHAT_YOU_LEFT_NOTICE
Definition: Channel.h:41

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

Referenced by LeaveChannel().

◆ Password()

void Channel::Password ( Player const *  player,
std::string const &  pass 
)
546{
547 ObjectGuid guid = player->GetGUID();
548
549 ChatHandler chat(player->GetSession());
550 if (!IsOn(guid))
551 {
552 WorldPacket data;
553 MakeNotMember(&data);
554 SendToOne(&data, guid);
555 return;
556 }
557
558 if (!playersStore[guid].IsModerator() && !AccountMgr::IsGMAccount(player->GetSession()->GetSecurity()))
559 {
560 WorldPacket data;
561 MakeNotModerator(&data);
562 SendToOne(&data, guid);
563 return;
564 }
565
567 {
568 WorldPacket data;
569 MakeNotModerator(&data);
570 SendToOne(&data, guid);
571 return;
572 }
573
574 _password = pass;
575
576 WorldPacket data;
577 MakePasswordChanged(&data, guid);
578 SendToAll(&data);
579
581}
@ CHANNEL_RIGHT_CANT_CHANGE_PASSWORD
Definition: Channel.h:143
void MakePasswordChanged(WorldPacket *data, ObjectGuid guid)
Definition: Channel.cpp:1009

References _channelRights, _password, CHANNEL_RIGHT_CANT_CHANGE_PASSWORD, ChannelRights::flags, Object::GetGUID(), WorldSession::GetSecurity(), Player::GetSession(), AccountMgr::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().

◆ RemoveWatching()

void Channel::RemoveWatching ( Player p)
1229{
1230 PlayersWatchingContainer::iterator itr = playersWatchingStore.find(p);
1231 if (itr != playersWatchingStore.end())
1232 playersWatchingStore.erase(itr);
1233}

References playersWatchingStore.

Referenced by KickOrBan(), and LeaveChannel().

◆ Say()

void Channel::Say ( ObjectGuid  guid,
std::string const &  what,
uint32  lang 
)
779{
780 if (what.empty())
781 return;
782
784 lang = LANG_UNIVERSAL;
785
786 if (!IsOn(guid))
787 {
788 WorldPacket data;
789 MakeNotMember(&data);
790 SendToOne(&data, guid);
791 return;
792 }
793
794 PlayerInfo& pinfo = playersStore[guid];
795
796 if (pinfo.IsMuted())
797 {
798 WorldPacket data;
799 MakeMuted(&data);
800 SendToOne(&data, guid);
801 return;
802 }
803
804 Player* player = pinfo.plrPtr;
805 WorldPacket data;
806
807 if (player)
808 {
809 ChatHandler::BuildChatPacket(data, CHAT_MSG_CHANNEL, Language(lang), player, player, what, 0, _name);
810 }
811 else
812 {
813 ChatHandler::BuildChatPacket(data, CHAT_MSG_CHANNEL, Language(lang), guid, guid, what, 0, "", "", 0, false, _name);
814 }
815
816 SendToAll(&data, pinfo.IsModerator() ? ObjectGuid::Empty : guid);
817}
@ CONFIG_ALLOW_TWO_SIDE_INTERACTION_CHANNEL
Definition: IWorld.h:79
@ CHAT_MSG_CHANNEL
Definition: SharedDefines.h:3141
Language
Definition: SharedDefines.h:706
@ LANG_UNIVERSAL
Definition: SharedDefines.h:707
void MakeMuted(WorldPacket *data)
Definition: Channel.cpp:1063
static 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:192

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
927{
928 for (PlayerContainer::const_iterator i = playersStore.begin(); i != playersStore.end(); ++i)
929 if (!guid || !i->second.plrPtr->GetSocial()->HasIgnore(guid))
930 i->second.plrPtr->GetSession()->SendPacket(data);
931}

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
934{
935 for (PlayerContainer::const_iterator i = playersStore.begin(); i != playersStore.end(); ++i)
936 if (i->first != who)
937 i->second.plrPtr->GetSession()->SendPacket(data);
938}

References playersStore.

◆ SendToAllWatching()

void Channel::SendToAllWatching ( WorldPacket data)
private
947{
948 for (PlayersWatchingContainer::const_iterator i = playersWatchingStore.begin(); i != playersWatchingStore.end(); ++i)
949 (*i)->GetSession()->SendPacket(data);
950}

References playersWatchingStore.

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

◆ SendToOne()

void Channel::SendToOne ( WorldPacket data,
ObjectGuid  who 
)
private
941{
943 player->GetSession()->SendPacket(data);
944}
Player * FindConnectedPlayer(ObjectGuid const guid)
Definition: ObjectAccessor.cpp:262

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)
692{
693 WorldPacket data;
694 if (IsOn(guid))
695 MakeChannelOwner(&data);
696 else
697 MakeNotMember(&data);
698 SendToOne(&data, guid);
699}
void MakeChannelOwner(WorldPacket *data)
Definition: Channel.cpp:1032

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

◆ SetMode()

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

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(), WorldSession::GetSecurity(), Player::GetSession(), Player::GetTeamId(), AccountMgr::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
289 {
290 PlayerInfo& pinfo = playersStore[guid];
291 if (pinfo.IsModerator() != set)
292 {
293 uint8 oldFlag = pinfo.flags;
294 pinfo.SetModerator(set);
295
296 WorldPacket data;
297 MakeModeChange(&data, guid, oldFlag);
298 SendToAll(&data);
299
300 FlagsNotify(pinfo.plrPtr);
301 }
302 }
void MakeModeChange(WorldPacket *data, ObjectGuid guid, uint8 oldflags)
Definition: Channel.cpp:1043

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
208{ SetMode(player, newname, true, true); }
void SetMode(Player const *player, std::string const &p2n, bool mod, bool set)
Definition: Channel.cpp:583

References SetMode().

Referenced by SetMode().

◆ SetMute() [1/2]

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

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
210{ SetMode(player, newname, false, true); }

References SetMode().

Referenced by SetMode().

◆ SetOwner() [1/2]

void Channel::SetOwner ( ObjectGuid  guid,
bool  exclaim = true 
)
878{
879 if (_ownerGUID)
880 {
881 // [] will re-add player after it possible removed
882 PlayerContainer::iterator p_itr = playersStore.find(_ownerGUID);
883 if (p_itr != playersStore.end())
884 {
885 p_itr->second.SetOwner(false);
886 FlagsNotify(p_itr->second.plrPtr);
887 }
888 }
889
890 _ownerGUID = guid;
891 if (_ownerGUID)
892 {
894
895 pinfo.SetModerator(true);
896 uint8 oldFlag = pinfo.flags;
897 pinfo.SetOwner(true);
898
899 bool notify = true;
901
902 if (player)
903 {
904 uint32 sec = player->GetSession()->GetSecurity();
905 notify = !(AccountMgr::IsGMAccount(sec) && sWorld->getBoolConfig(CONFIG_SILENTLY_GM_JOIN_TO_CHANNEL));
906 }
907
908 WorldPacket data;
909
910 if (notify)
911 {
912 MakeModeChange(&data, _ownerGUID, oldFlag);
913 SendToAll(&data);
914 }
915
916 FlagsNotify(pinfo.plrPtr);
917
918 if (exclaim && notify)
919 {
921 SendToAll(&data);
922 }
923 }
924}
Player * FindPlayer(ObjectGuid const guid)
Definition: ObjectAccessor.cpp:250
void MakeOwnerChanged(WorldPacket *data, ObjectGuid guid)
Definition: Channel.cpp:1015

References _ownerGUID, CONFIG_SILENTLY_GM_JOIN_TO_CHANNEL, ObjectAccessor::FindPlayer(), Channel::PlayerInfo::flags, FlagsNotify(), WorldSession::GetSecurity(), Player::GetSession(), AccountMgr::IsGMAccount(), MakeModeChange(), MakeOwnerChanged(), playersStore, Channel::PlayerInfo::plrPtr, SendToAll(), Channel::PlayerInfo::SetModerator(), Channel::PlayerInfo::SetOwner(), and sWorld.

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

◆ SetOwner() [2/2]

void Channel::SetOwner ( Player const *  player,
std::string const &  name 
)
655{
656 ObjectGuid guid = player->GetGUID();
657 uint32 sec = player->GetSession()->GetSecurity();
658
659 if (!IsOn(guid))
660 {
661 WorldPacket data;
662 MakeNotMember(&data);
663 SendToOne(&data, guid);
664 return;
665 }
666
667 bool isGoodConstantModerator = _channelRights.moderators.find(player->GetSession()->GetAccountId()) != _channelRights.moderators.end();
668 if (!AccountMgr::IsGMAccount(sec) && guid != _ownerGUID && !isGoodConstantModerator)
669 {
670 WorldPacket data;
671 MakeNotOwner(&data);
672 SendToOne(&data, guid);
673 return;
674 }
675
676 Player* newp = ObjectAccessor::FindPlayerByName(newname, false);
677 ObjectGuid victim = newp ? newp->GetGUID() : ObjectGuid::Empty;
678
679 if (!victim || !IsOn(victim) || (newp->GetTeamId() != player->GetTeamId() &&
681 {
682 WorldPacket data;
683 MakePlayerNotFound(&data, newname);
684 SendToOne(&data, guid);
685 return;
686 }
687
688 SetOwner(victim);
689}

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

◆ SetPassword()

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

References _password.

Referenced by ChannelMgr::LoadChannels().

◆ ToggleModeration()

void Channel::ToggleModeration ( Player p)
1236{
1237 ObjectGuid guid = player->GetGUID();
1238
1239 if (!IsOn(guid))
1240 {
1241 WorldPacket data;
1242 MakeNotMember(&data);
1243 SendToOne(&data, guid);
1244 return;
1245 }
1246
1247 const uint32 level = sWorld->getIntConfig(CONFIG_GM_LEVEL_CHANNEL_MODERATION);
1248 const bool gm = (level && player->GetSession()->GetSecurity() >= level);
1249
1250 if (!playersStore[guid].IsModerator() && !gm)
1251 {
1252 WorldPacket data;
1253 MakeNotModerator(&data);
1254 SendToOne(&data, guid);
1255 return;
1256 }
1257
1258 // toggle channel moderation
1260
1261 WorldPacket data;
1262 if (_moderation)
1263 {
1264 MakeModerationOn(&data, guid);
1265 }
1266 else
1267 {
1268 MakeModerationOff(&data, guid);
1269 }
1270
1271 SendToAll(&data);
1272}
@ CONFIG_GM_LEVEL_CHANNEL_MODERATION
Definition: IWorld.h:405
bool _moderation
Definition: Channel.h:323
void MakeModerationOn(WorldPacket *data, ObjectGuid guid)
Definition: Channel.cpp:1274
void MakeModerationOff(WorldPacket *data, ObjectGuid guid)
Definition: Channel.cpp:1280

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)
538{
539 if (!IsBanned(guid))
540 return;
541 bannedStore.erase(guid);
543}
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 
)
478{
479 uint32 sec = player->GetSession()->GetSecurity();
480 ObjectGuid good = player->GetGUID();
481
482 if (!IsOn(good))
483 {
484 WorldPacket data;
485 MakeNotMember(&data);
486 SendToOne(&data, good);
487 return;
488 }
489
490 if (!playersStore[good].IsModerator() && !AccountMgr::IsGMAccount(sec))
491 {
492 WorldPacket data;
493 MakeNotModerator(&data);
494 SendToOne(&data, good);
495 return;
496 }
497
498 ObjectGuid victim;
499 if (ObjectGuid guid = sCharacterCache->GetCharacterGuidByName(badname))
500 {
501 victim = guid;
502 }
503
504 if (!victim || !IsBanned(victim))
505 {
506 WorldPacket data;
507 MakePlayerNotFound(&data, badname);
508 SendToOne(&data, good);
509 return;
510 }
511
512 bool isConstantModerator = _channelRights.moderators.find(player->GetSession()->GetAccountId()) != _channelRights.moderators.end();
513 if (!AccountMgr::IsGMAccount(sec) && !isConstantModerator)
514 {
516 {
517 WorldPacket data;
518 MakeNotModerator(&data);
519 SendToOne(&data, good);
520 return;
521 }
522 }
523
525 LOG_GM(player->GetSession()->GetAccountId(), "Command: /unban {} {} (Moderator {} [{}, account: {}] unbanned {} [{}])",
526 GetName(), badname, player->GetName(), player->GetGUID().ToString(), player->GetSession()->GetAccountId(),
527 badname, victim.ToString());
528
529 bannedStore.erase(victim);
531
532 WorldPacket data;
533 MakePlayerUnbanned(&data, victim, good);
534 SendToAll(&data);
535}
#define LOG_GM(accountId__,...)
Definition: Log.h:178
void MakePlayerUnbanned(WorldPacket *data, ObjectGuid bad, ObjectGuid good)
Definition: Channel.cpp:1087
std::string ToString() const
Definition: ObjectGuid.cpp:47

References _channelRights, bannedStore, CHANNEL_RIGHT_CANT_BAN, ChannelRights::flags, WorldSession::GetAccountId(), Object::GetGUID(), GetName(), WorldObject::GetName(), WorldSession::GetSecurity(), Player::GetSession(), IsBanned(), AccountMgr::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
209{ SetMode(player, newname, true, false); }

References SetMode().

◆ UnsetMute()

void Channel::UnsetMute ( Player const *  player,
std::string const &  newname 
)
inline
211{ 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 
)
953{
954}

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(), and UnBan().

◆ playersStore

◆ playersWatchingStore

PlayersWatchingContainer Channel::playersWatchingStore
private