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}
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:143
#define sWorld
Definition: World.h:447
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:330
bool _isOwnerGM
Definition: Channel.h:328
ChannelRights _channelRights
Definition: Channel.h:336
bool _announce
Definition: Channel.h:324
uint8 _flags
Definition: Channel.h:329
bool _ownership
Definition: Channel.h:326
std::string _password
Definition: Channel.h:335
uint32 _channelDBId
Definition: Channel.h:331
TeamId _teamId
Definition: Channel.h:332
std::string _name
Definition: Channel.h:334
bool _IsSaved
Definition: Channel.h:327
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:338

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)
1211{
1212 if (!IsOn(p->GetGUID()))
1213 return;
1214 playersWatchingStore.insert(p);
1215}
PlayersWatchingContainer playersWatchingStore
Definition: Channel.h:339
bool IsOn(ObjectGuid who) const
Definition: Channel.h:276
static ObjectGuid GetGUID(Object const *o)
Definition: Object.h:106

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

◆ Announce()

void Channel::Announce ( Player const *  player)
728{
729 ObjectGuid guid = player->GetGUID();
730
731 if (!IsOn(guid))
732 {
733 WorldPacket data;
734 MakeNotMember(&data);
735 SendToOne(&data, guid);
736 return;
737 }
738
739 if (!playersStore[guid].IsModerator() && !player->GetSession()->IsGMAccount())
740 {
741 WorldPacket data;
742 MakeNotModerator(&data);
743 SendToOne(&data, guid);
744 return;
745 }
746
748 {
749 WorldPacket data;
750 MakeNotModerator(&data);
751 SendToOne(&data, guid);
752 return;
753 }
754
756
757 WorldPacket data;
758 if (_announce)
759 MakeAnnouncementsOn(&data, guid);
760 else
761 MakeAnnouncementsOff(&data, guid);
762 SendToAll(&data);
763
765}
void MakeNotMember(WorldPacket *data)
Definition: Channel.cpp:988
void MakeAnnouncementsOn(WorldPacket *data, ObjectGuid guid)
Definition: Channel.cpp:1040
void SendToOne(WorldPacket *data, ObjectGuid who)
Definition: Channel.cpp:924
void UpdateChannelInDB() const
Definition: Channel.cpp:102
PlayerContainer playersStore
Definition: Channel.h:337
void MakeNotModerator(WorldPacket *data)
Definition: Channel.cpp:993
void MakeAnnouncementsOff(WorldPacket *data, ObjectGuid guid)
Definition: Channel.cpp:1046
void SendToAll(WorldPacket *data, ObjectGuid guid=ObjectGuid::Empty)
Definition: Channel.cpp:910
Definition: ObjectGuid.h:120
Definition: WorldPacket.h:27

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
199{ KickOrBan(player, badname, true); }
void KickOrBan(Player const *player, std::string const &badname, bool ban)
Definition: Channel.cpp:318

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:51
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:360

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 
)
946{
947}

◆ FlagsNotify()

void Channel::FlagsNotify ( Player p)
1194{
1196 return;
1198 return;
1199
1200 WorldPacket data(SMSG_USERLIST_UPDATE, 8 + 1 + 1 + 4 + GetName().size());
1201 data << p->GetGUID();
1202 data << uint8(GetPlayerFlags(p->GetGUID()));
1203 data << uint8(GetFlags());
1204 data << uint32(GetNumPlayers());
1205 data << GetName();
1206
1207 SendToAllWatching(&data);
1208}
std::uint8_t uint8
Definition: Define.h:110
std::uint32_t uint32
Definition: Define.h:108
@ 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:930
std::string const & GetName() const
Definition: Channel.h:183
uint8 GetPlayerFlags(ObjectGuid guid) const
Definition: Channel.h:284
uint32 GetNumPlayers() const
Definition: Channel.h:191
uint8 GetFlags() const
Definition: Channel.h:192
WorldSession * GetSession() const
Definition: Player.h:1961
AccountTypes GetSecurity() const
Definition: WorldSession.h:361

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
285 {
286 PlayerContainer::const_iterator itr = playersStore.find(guid);
287 return itr != playersStore.end() ? itr->second.flags : 0;
288 }

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 
)
809{
810 ObjectGuid guid = player->GetGUID();
811
812 if (!IsOn(guid))
813 {
814 WorldPacket data;
815 MakeNotMember(&data);
816 SendToOne(&data, guid);
817 return;
818 }
819
820 Player* newp = ObjectAccessor::FindPlayerByName(newname, false);
821 if (!newp || !newp->isGMVisible())
822 {
823 WorldPacket data;
824 MakePlayerNotFound(&data, newname);
825 SendToOne(&data, guid);
826 return;
827 }
828
829 if (IsBanned(newp->GetGUID()))
830 {
831 WorldPacket data;
832 MakePlayerInviteBanned(&data, newname);
833 SendToOne(&data, guid);
834 return;
835 }
836
837 if (newp->GetTeamId() != player->GetTeamId())
838 {
839 WorldPacket data;
841 SendToOne(&data, guid);
842 return;
843 }
844
845 if (IsOn(newp->GetGUID()))
846 {
847 WorldPacket data;
848 MakePlayerAlreadyMember(&data, newp->GetGUID());
849 SendToOne(&data, guid);
850 return;
851 }
852
853 if (!newp->GetSocial()->HasIgnore(guid))
854 {
855 WorldPacket data;
856 MakeInvite(&data, guid);
857 SendToOne(&data, newp->GetGUID());
858 data.clear();
859 }
860
861 WorldPacket data;
862 MakePlayerInvited(&data, newp->GetName());
863 SendToOne(&data, guid);
864}
Player * FindPlayerByName(std::string const &name, bool checkInWorld=true)
Definition: ObjectAccessor.cpp:274
void MakePlayerNotFound(WorldPacket *data, std::string const &name)
Definition: Channel.cpp:1010
void MakePlayerInvited(WorldPacket *data, std::string const &name)
Definition: Channel.cpp:1121
void MakePlayerInviteBanned(WorldPacket *data, std::string const &name)
Definition: Channel.cpp:1127
void MakeInviteWrongFaction(WorldPacket *data)
Definition: Channel.cpp:1101
void MakeInvite(WorldPacket *data, ObjectGuid guid)
Definition: Channel.cpp:1095
void MakePlayerAlreadyMember(WorldPacket *data, ObjectGuid guid)
Definition: Channel.cpp:1089
bool IsBanned(ObjectGuid guid) const
Definition: Channel.cpp:96
std::string const & GetName() const
Definition: Object.h:446
Definition: Player.h:1056
bool isGMVisible() const
Definition: Player.h:1154
TeamId GetTeamId(bool original=false) const
Definition: Player.h:2072
PlayerSocial * GetSocial()
Definition: Player.h:1131
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
201 if (_announce && ShouldAnnouncePlayer(player))
202 {
203 WorldPacket data;
204 MakeJoined(&data, guid);
205 SendToAll(&data);
206 }
207
208 PlayerInfo pinfo;
209 pinfo.player = guid;
210 pinfo.flags = MEMBER_FLAG_NONE;
211 pinfo.plrPtr = player;
212
213 playersStore[guid] = pinfo;
214
215 if (_channelRights.joinMessage.length())
217
218 WorldPacket data;
219 MakeYouJoined(&data);
220 SendToOne(&data, guid);
221
222 JoinNotify(player);
223
224 playersStore[guid].SetOwnerGM(player->GetSession()->IsGMAccount());
225
226 // Custom channel handling
227 if (!IsConstant())
228 {
229 // Update last_used timestamp in db
230 if (!playersStore.empty())
232
234 {
235 playersStore[guid].SetModerator(true);
236 FlagsNotify(player);
237 }
238
239 // If the channel has no owner yet and ownership is allowed, set the new owner.
240 // If the channel owner is a GM and the config SilentGMJoinChannel is enabled, set the new owner
242 {
243 _isOwnerGM = playersStore[guid].IsOwnerGM();
244 SetOwner(guid, false);
245 }
246
248 playersStore[guid].SetMuted(true);
249 }
250}
@ MEMBER_FLAG_NONE
Definition: Channel.h:111
@ CONFIG_SILENTLY_GM_JOIN_TO_CHANNEL
Definition: IWorld.h:104
@ CONFIG_RESTRICTED_LFG_CHANNEL
Definition: IWorld.h:103
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:956
void JoinNotify(Player *p)
Definition: Channel.cpp:1160
bool HasFlag(uint8 flag) const
Definition: Channel.h:193
ObjectGuid _ownerGUID
Definition: Channel.h:333
void SetOwner(ObjectGuid guid, bool exclaim=true)
Definition: Channel.cpp:866
bool ShouldAnnouncePlayer(Player const *player) const
Definition: Channel.cpp:936
void MakeYouJoined(WorldPacket *data)
Definition: Channel.cpp:968
void MakeNotInLfg(WorldPacket *data)
Definition: Channel.cpp:1143
void MakeBanned(WorldPacket *data)
Definition: Channel.cpp:1064
void MakeWrongPassword(WorldPacket *data)
Definition: Channel.cpp:983
void UpdateChannelUseageInDB() const
Definition: Channel.cpp:116
void FlagsNotify(Player *p)
Definition: Channel.cpp:1193
Definition: Chat.h:38
void PSendSysMessage(char const *fmt, Args &&... args)
Definition: Chat.h:60
Definition: Player.h:336
Group * GetGroup()
Definition: Player.h:2431
void JoinedChannel(Channel *c)
Definition: Player.cpp:4907
bool IsGMAccount() const
Definition: WorldSession.cpp:179
uint32 GetAccountId() const
Definition: WorldSession.h:363

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(), WorldSession::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(), ShouldAnnouncePlayer(), sWorld, and UpdateChannelUseageInDB().

Referenced by Player::UpdateLocalChannels().

◆ JoinNotify()

void Channel::JoinNotify ( Player p)
1161{
1163 return;
1165 return;
1166
1167 WorldPacket data(SMSG_USERLIST_ADD, 8 + 1 + 1 + 4 + GetName().size());
1168 data << p->GetGUID();
1169 data << uint8(GetPlayerFlags(p->GetGUID()));
1170 data << uint8(GetFlags());
1171 data << uint32(GetNumPlayers());
1172 data << GetName();
1173
1174 SendToAllWatching(&data);
1175}
@ 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 
)
319{
320 ObjectGuid good = player->GetGUID();
321
322 if (!IsOn(good))
323 {
324 WorldPacket data;
325 MakeNotMember(&data);
326 SendToOne(&data, good);
327 return;
328 }
329
330 if (!playersStore[good].IsModerator() && !player->GetSession()->IsGMAccount())
331 {
332 WorldPacket data;
333 MakeNotModerator(&data);
334 SendToOne(&data, good);
335 return;
336 }
337
338 bool banOffline = false; // pussywizard
339 bool isGoodConstantModerator = _channelRights.moderators.find(player->GetSession()->GetAccountId()) != _channelRights.moderators.end();
340
341 ObjectGuid victim;
342 uint32 badAccId = 0;
343 Player* bad = ObjectAccessor::FindPlayerByName(badname, false);
344 if (bad)
345 {
346 victim = bad->GetGUID();
347 badAccId = bad->GetSession()->GetAccountId();
348 }
349
350 bool isOnChannel = victim && IsOn(victim);
351 if (!isOnChannel)
352 {
353 if (ban && (player->GetSession()->IsGMAccount() || isGoodConstantModerator))
354 {
355 if (ObjectGuid guid = sCharacterCache->GetCharacterGuidByName(badname))
356 {
357 if (CharacterCacheEntry const* gpd = sCharacterCache->GetCharacterCacheByGuid(guid))
358 {
359 if (Player::TeamIdForRace(gpd->Race) == Player::TeamIdForRace(player->getRace()))
360 {
361 banOffline = true;
362 victim = guid;
363 badAccId = gpd->AccountId;
364 }
365 else
366 {
367 ChatHandler(player->GetSession()).PSendSysMessage("Character %s has other faction!", badname.c_str());
368 return;
369 }
370 }
371 }
372
373 if (!banOffline)
374 {
375 WorldPacket data;
376 MakePlayerNotFound(&data, badname);
377 SendToOne(&data, good);
378 return;
379 }
380 }
381 else
382 {
383 WorldPacket data;
384 MakePlayerNotFound(&data, badname);
385 SendToOne(&data, good);
386 return;
387 }
388 }
389
390 bool changeowner = _ownerGUID == victim;
391 bool isBadConstantModerator = _channelRights.moderators.find(badAccId) != _channelRights.moderators.end();
392
393 if (!player->GetSession()->IsGMAccount() && !isGoodConstantModerator)
394 {
395 if (changeowner && good != _ownerGUID)
396 {
397 WorldPacket data;
398 MakeNotOwner(&data);
399 SendToOne(&data, good);
400 return;
401 }
402
404 {
405 WorldPacket data;
406 MakeNotModerator(&data);
407 SendToOne(&data, good);
408 return;
409 }
410
411 if (isBadConstantModerator || bad->GetSession()->IsGMAccount())
412 {
413 WorldPacket data;
414 MakeNotModerator(&data);
415 SendToOne(&data, good);
416 return;
417 }
418 }
419
420 if (ban)
421 {
422 if (!IsBanned(victim))
423 {
426
427 if (ShouldAnnouncePlayer(player))
428 {
429 WorldPacket data;
430 MakePlayerBanned(&data, victim, good);
431 SendToAll(&data);
432 }
433 }
434 }
435 else if (ShouldAnnouncePlayer(player))
436 {
437 WorldPacket data;
438 MakePlayerKicked(&data, victim, good);
439 SendToAll(&data);
440 }
441
442 if (isOnChannel)
443 {
444 playersStore.erase(victim);
445 bad->LeftChannel(this);
446 RemoveWatching(bad);
447 LeaveNotify(bad);
448 }
449
450 if (changeowner && _ownership)
451 {
452 if (good != victim)
453 SetOwner(good);
454 else if (!playersStore.empty())
455 {
456 ObjectGuid newowner;
457 for (Channel::PlayerContainer::const_iterator itr = playersStore.begin(); itr != playersStore.end(); ++itr)
458 {
459 newowner = itr->second.player;
460 if (!itr->second.plrPtr->GetSession()->GetSecurity())
461 break;
462 }
463 SetOwner(newowner);
464 }
465 else
467 }
468}
#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:1217
void MakePlayerBanned(WorldPacket *data, ObjectGuid bad, ObjectGuid good)
Definition: Channel.cpp:1069
void MakeNotOwner(WorldPacket *data)
Definition: Channel.cpp:1016
void AddChannelBanToDB(ObjectGuid guid, uint32 time) const
Definition: Channel.cpp:123
void MakePlayerKicked(WorldPacket *data, ObjectGuid bad, ObjectGuid good)
Definition: Channel.cpp:1057
void LeaveNotify(Player *p)
Definition: Channel.cpp:1177
static ObjectGuid const Empty
Definition: ObjectGuid.h:122
static TeamId TeamIdForRace(uint8 race)
Definition: Player.cpp:5745
void LeftChannel(Channel *c)
Definition: Player.cpp:4912

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

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(), and Player::UpdateLocalChannels().

◆ LeaveNotify()

void Channel::LeaveNotify ( Player p)
1178{
1180 return;
1182 return;
1183
1184 WorldPacket data(SMSG_USERLIST_REMOVE, 8 + 1 + 4 + GetName().size());
1185 data << p->GetGUID();
1186 data << uint8(GetFlags());
1187 data << uint32(GetNumPlayers());
1188 data << GetName();
1189
1190 SendToAllWatching(&data);
1191}
@ 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)
692{
693 ObjectGuid guid = player->GetGUID();
694
695 if (!IsOn(guid))
696 {
697 WorldPacket data;
698 MakeNotMember(&data);
699 SendToOne(&data, guid);
700 return;
701 }
702
703 LOG_DEBUG("chat.system", "SMSG_CHANNEL_LIST {} Channel: {}", player->GetSession()->GetPlayerInfo(), GetName());
704 WorldPacket data(SMSG_CHANNEL_LIST, 1 + (GetName().size() + 1) + 1 + 4 + playersStore.size() * (8 + 1));
705 data << uint8(1); // channel type?
706 data << GetName(); // channel name
707 data << uint8(GetFlags()); // channel flags?
708
709 size_t pos = data.wpos();
710 data << uint32(0); // size of list, placeholder
711
712 uint32 count = 0;
714 for (PlayerContainer::const_iterator i = playersStore.begin(); i != playersStore.end(); ++i)
715 if (AccountMgr::IsPlayerAccount(i->second.plrPtr->GetSession()->GetSecurity()))
716 {
717 data << i->first;
718 data << uint8(i->second.flags); // flags seems to be changed...
719 ++count;
720 }
721
722 data.put<uint32>(pos, count);
723
724 SendToOne(&data, guid);
725}
#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
1047{
1049 *data << guid;
1050}
@ CHAT_ANNOUNCEMENTS_OFF_NOTICE
Definition: Channel.h:52
void MakeNotifyPacket(WorldPacket *data, uint8 notify_type)
Definition: Channel.cpp:949

References CHAT_ANNOUNCEMENTS_OFF_NOTICE, and MakeNotifyPacket().

Referenced by Announce().

◆ MakeAnnouncementsOn()

void Channel::MakeAnnouncementsOn ( WorldPacket data,
ObjectGuid  guid 
)
private
1041{
1043 *data << guid;
1044}
@ 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
1065{
1067}
@ CHAT_BANNED_NOTICE
Definition: Channel.h:57

References CHAT_BANNED_NOTICE, and MakeNotifyPacket().

Referenced by JoinChannel().

◆ MakeChannelOwner()

void Channel::MakeChannelOwner ( WorldPacket data)
private
1022{
1023 std::string name = "";
1024
1025 if (!sCharacterCache->GetCharacterNameByGuid(_ownerGUID, name) || name.empty())
1026 name = "PLAYER_NOT_FOUND";
1027
1029 *data << ((IsConstant() || !_ownerGUID) ? "Nobody" : name);
1030}
@ 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
1112{
1114}
@ CHAT_INVALID_NAME_NOTICE
Definition: Channel.h:65

References CHAT_INVALID_NAME_NOTICE, and MakeNotifyPacket().

◆ MakeInvite()

void Channel::MakeInvite ( WorldPacket data,
ObjectGuid  guid 
)
private
1096{
1098 *data << guid;
1099}
@ CHAT_INVITE_NOTICE
Definition: Channel.h:62

References CHAT_INVITE_NOTICE, and MakeNotifyPacket().

Referenced by Invite().

◆ MakeInviteWrongFaction()

void Channel::MakeInviteWrongFaction ( WorldPacket data)
private
1102{
1104}
@ 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
957{
959 *data << guid;
960}
@ 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
963{
965 *data << guid;
966}
@ 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
1033{
1035 *data << guid;
1036 *data << uint8(oldflags);
1037 *data << uint8(GetPlayerFlags(guid));
1038}
@ 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
1270{
1272 *data << guid;
1273}
@ 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
1264{
1266 *data << guid;
1267}
@ 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
1053{
1055}
@ CHAT_MUTED_NOTICE
Definition: Channel.h:55

References CHAT_MUTED_NOTICE, and MakeNotifyPacket().

Referenced by Say().

◆ MakeNotifyPacket()

◆ MakeNotInArea()

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

References CHAT_NOT_IN_AREA_NOTICE, and MakeNotifyPacket().

◆ MakeNotInLfg()

void Channel::MakeNotInLfg ( WorldPacket data)
private
1144{
1146}
@ 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
1117{
1119}
@ CHAT_NOT_MODERATED_NOTICE
Definition: Channel.h:66

References CHAT_NOT_MODERATED_NOTICE, and MakeNotifyPacket().

◆ MakeNotModerator()

void Channel::MakeNotModerator ( WorldPacket data)
private
994{
996}
@ 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
1017{
1019}
@ 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
1005{
1007 *data << guid;
1008}
@ 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
999{
1001 *data << guid;
1002}
@ 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
1090{
1092 *data << guid;
1093}
@ 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
1070{
1072 *data << bad;
1073 *data << good;
1074}
@ 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
1128{
1130 *data << name;
1131}
@ 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
1122{
1124 *data << name;
1125}
@ 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
1058{
1060 *data << bad;
1061 *data << good;
1062}
@ 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
1084{
1086 *data << name;
1087}
@ 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
1011{
1013 *data << name;
1014}
@ 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
1077{
1079 *data << bad;
1080 *data << good;
1081}
@ 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
1134{
1136}
@ CHAT_THROTTLED_NOTICE
Definition: Channel.h:69

References CHAT_THROTTLED_NOTICE, and MakeNotifyPacket().

◆ MakeVoiceOff()

void Channel::MakeVoiceOff ( WorldPacket data,
ObjectGuid  guid 
)
private
1155{
1157 *data << guid;
1158}
@ CHAT_VOICE_OFF_NOTICE
Definition: Channel.h:73

References CHAT_VOICE_OFF_NOTICE, and MakeNotifyPacket().

◆ MakeVoiceOn()

void Channel::MakeVoiceOn ( WorldPacket data,
ObjectGuid  guid 
)
private
1149{
1151 *data << guid;
1152}
@ CHAT_VOICE_ON_NOTICE
Definition: Channel.h:72

References CHAT_VOICE_ON_NOTICE, and MakeNotifyPacket().

◆ MakeWrongFaction()

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

References CHAT_WRONG_FACTION_NOTICE, and MakeNotifyPacket().

◆ MakeWrongPassword()

void Channel::MakeWrongPassword ( WorldPacket data)
private
984{
986}
@ 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
969{
971 *data << uint8(GetFlags());
972 *data << uint32(GetChannelId());
973 *data << uint32(0);
974}
@ 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
977{
979 *data << uint32(GetChannelId());
980 *data << uint8(IsConstant());
981}
@ 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 
)
538{
539 ObjectGuid guid = player->GetGUID();
540
541 ChatHandler chat(player->GetSession());
542 if (!IsOn(guid))
543 {
544 WorldPacket data;
545 MakeNotMember(&data);
546 SendToOne(&data, guid);
547 return;
548 }
549
550 if (!playersStore[guid].IsModerator() && !player->GetSession()->IsGMAccount())
551 {
552 WorldPacket data;
553 MakeNotModerator(&data);
554 SendToOne(&data, guid);
555 return;
556 }
557
559 {
560 WorldPacket data;
561 MakeNotModerator(&data);
562 SendToOne(&data, guid);
563 return;
564 }
565
566 _password = pass;
567
568 WorldPacket data;
569 MakePasswordChanged(&data, guid);
570 SendToAll(&data);
571
573}
@ CHANNEL_RIGHT_CANT_CHANGE_PASSWORD
Definition: Channel.h:143
void MakePasswordChanged(WorldPacket *data, ObjectGuid guid)
Definition: Channel.cpp:998

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().

◆ RemoveWatching()

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

References playersWatchingStore.

Referenced by KickOrBan(), and LeaveChannel().

◆ Say()

void Channel::Say ( ObjectGuid  guid,
std::string const &  what,
uint32  lang 
)
768{
769 if (what.empty())
770 return;
771
773 lang = LANG_UNIVERSAL;
774
775 if (!IsOn(guid))
776 {
777 WorldPacket data;
778 MakeNotMember(&data);
779 SendToOne(&data, guid);
780 return;
781 }
782
783 PlayerInfo& pinfo = playersStore[guid];
784
785 if (pinfo.IsMuted())
786 {
787 WorldPacket data;
788 MakeMuted(&data);
789 SendToOne(&data, guid);
790 return;
791 }
792
793 Player* player = pinfo.plrPtr;
794 WorldPacket data;
795
796 if (player)
797 {
798 ChatHandler::BuildChatPacket(data, CHAT_MSG_CHANNEL, Language(lang), player, player, what, 0, _name);
799 }
800 else
801 {
802 ChatHandler::BuildChatPacket(data, CHAT_MSG_CHANNEL, Language(lang), guid, guid, what, 0, "", "", 0, false, _name);
803 }
804
805 SendToAll(&data, pinfo.IsModerator() ? ObjectGuid::Empty : guid);
806}
@ CONFIG_ALLOW_TWO_SIDE_INTERACTION_CHANNEL
Definition: IWorld.h:79
@ 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:1052
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:201

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
911{
912 for (PlayerContainer::const_iterator i = playersStore.begin(); i != playersStore.end(); ++i)
913 if (!guid || !i->second.plrPtr->GetSocial()->HasIgnore(guid))
914 i->second.plrPtr->GetSession()->SendPacket(data);
915}

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
918{
919 for (PlayerContainer::const_iterator i = playersStore.begin(); i != playersStore.end(); ++i)
920 if (i->first != who)
921 i->second.plrPtr->GetSession()->SendPacket(data);
922}

References playersStore.

◆ SendToAllWatching()

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

References playersWatchingStore.

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

◆ SendToOne()

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

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)
682{
683 WorldPacket data;
684 if (IsOn(guid))
685 MakeChannelOwner(&data);
686 else
687 MakeNotMember(&data);
688 SendToOne(&data, guid);
689}
void MakeChannelOwner(WorldPacket *data)
Definition: Channel.cpp:1021

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

◆ SetMode()

void Channel::SetMode ( Player const *  player,
std::string const &  p2n,
bool  mod,
bool  set 
)
576{
577 ObjectGuid guid = player->GetGUID();
578
579 if (!IsOn(guid))
580 {
581 WorldPacket data;
582 MakeNotMember(&data);
583 SendToOne(&data, guid);
584 return;
585 }
586
587 if (!playersStore[guid].IsModerator() && !player->GetSession()->IsGMAccount())
588 {
589 WorldPacket data;
590 MakeNotModerator(&data);
591 SendToOne(&data, guid);
592 return;
593 }
594
595 if (guid == _ownerGUID && std::string(p2n) == player->GetName() && mod)
596 return;
597
598 Player* newp = ObjectAccessor::FindPlayerByName(p2n, false);
599 ObjectGuid victim = newp ? newp->GetGUID() : ObjectGuid::Empty;
600
601 if (!victim || !IsOn(victim) ||
602 // allow make moderator from another team only if both is GMs
603 // at this moment this only way to show channel post for GM from another team
604 ((!player->GetSession()->IsGMAccount() || !newp->GetSession()->IsGMAccount()) && player->GetTeamId() != newp->GetTeamId() &&
606 {
607 WorldPacket data;
608 MakePlayerNotFound(&data, p2n);
609 SendToOne(&data, guid);
610 return;
611 }
612
613 if (_ownerGUID == victim && _ownerGUID != guid)
614 {
615 WorldPacket data;
616 MakeNotOwner(&data);
617 SendToOne(&data, guid);
618 return;
619 }
620
621 if (mod)
622 {
623 bool isBadConstantModerator = _channelRights.moderators.find(newp->GetSession()->GetAccountId()) != _channelRights.moderators.end();
624 if (!isBadConstantModerator)
625 SetModerator(newp->GetGUID(), set);
626 }
627 else
628 {
629 bool isGoodConstantModerator = _channelRights.moderators.find(player->GetSession()->GetAccountId()) != _channelRights.moderators.end();
630 if (!player->GetSession()->IsGMAccount() && !isGoodConstantModerator)
631 {
633 {
634 WorldPacket data;
635 MakeNotModerator(&data);
636 SendToOne(&data, guid);
637 return;
638 }
639 }
640
641 SetMute(newp->GetGUID(), set);
642 }
643}
@ 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(), 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
291 {
292 PlayerInfo& pinfo = playersStore[guid];
293 if (pinfo.IsModerator() != set)
294 {
295 uint8 oldFlag = pinfo.flags;
296 pinfo.SetModerator(set);
297
298 WorldPacket data;
299 MakeModeChange(&data, guid, oldFlag);
300 SendToAll(&data);
301
302 FlagsNotify(pinfo.plrPtr);
303 }
304 }
void MakeModeChange(WorldPacket *data, ObjectGuid guid, uint8 oldflags)
Definition: Channel.cpp:1032

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

References SetMode().

Referenced by SetMode().

◆ SetMute() [1/2]

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

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

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

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
190{ _password = npassword; }

References _password.

Referenced by ChannelMgr::LoadChannels().

◆ ShouldAnnouncePlayer()

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

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)
1225{
1226 ObjectGuid guid = player->GetGUID();
1227
1228 if (!IsOn(guid))
1229 {
1230 WorldPacket data;
1231 MakeNotMember(&data);
1232 SendToOne(&data, guid);
1233 return;
1234 }
1235
1236 const uint32 level = sWorld->getIntConfig(CONFIG_GM_LEVEL_CHANNEL_MODERATION);
1237 const bool gm = (level && player->GetSession()->GetSecurity() >= level);
1238
1239 if (!playersStore[guid].IsModerator() && !gm)
1240 {
1241 WorldPacket data;
1242 MakeNotModerator(&data);
1243 SendToOne(&data, guid);
1244 return;
1245 }
1246
1247 // toggle channel moderation
1249
1250 WorldPacket data;
1251 if (_moderation)
1252 {
1253 MakeModerationOn(&data, guid);
1254 }
1255 else
1256 {
1257 MakeModerationOff(&data, guid);
1258 }
1259
1260 SendToAll(&data);
1261}
@ CONFIG_GM_LEVEL_CHANNEL_MODERATION
Definition: IWorld.h:409
bool _moderation
Definition: Channel.h:325
void MakeModerationOn(WorldPacket *data, ObjectGuid guid)
Definition: Channel.cpp:1263
void MakeModerationOff(WorldPacket *data, ObjectGuid guid)
Definition: Channel.cpp:1269

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)
530{
531 if (!IsBanned(guid))
532 return;
533 bannedStore.erase(guid);
535}
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 
)
471{
472 ObjectGuid good = player->GetGUID();
473
474 if (!IsOn(good))
475 {
476 WorldPacket data;
477 MakeNotMember(&data);
478 SendToOne(&data, good);
479 return;
480 }
481
482 if (!playersStore[good].IsModerator() && !player->GetSession()->IsGMAccount())
483 {
484 WorldPacket data;
485 MakeNotModerator(&data);
486 SendToOne(&data, good);
487 return;
488 }
489
490 ObjectGuid victim;
491 if (ObjectGuid guid = sCharacterCache->GetCharacterGuidByName(badname))
492 {
493 victim = guid;
494 }
495
496 if (!victim || !IsBanned(victim))
497 {
498 WorldPacket data;
499 MakePlayerNotFound(&data, badname);
500 SendToOne(&data, good);
501 return;
502 }
503
504 bool isConstantModerator = _channelRights.moderators.find(player->GetSession()->GetAccountId()) != _channelRights.moderators.end();
505 if (!player->GetSession()->IsGMAccount() && !isConstantModerator)
506 {
508 {
509 WorldPacket data;
510 MakeNotModerator(&data);
511 SendToOne(&data, good);
512 return;
513 }
514 }
515
517 LOG_GM(player->GetSession()->GetAccountId(), "Command: /unban {} {} (Moderator {} [{}, account: {}] unbanned {} [{}])",
518 GetName(), badname, player->GetName(), player->GetGUID().ToString(), player->GetSession()->GetAccountId(),
519 badname, victim.ToString());
520
521 bannedStore.erase(victim);
523
524 WorldPacket data;
525 MakePlayerUnbanned(&data, victim, good);
526 SendToAll(&data);
527}
#define LOG_GM(accountId__,...)
Definition: Log.h:176
void MakePlayerUnbanned(WorldPacket *data, ObjectGuid bad, ObjectGuid good)
Definition: Channel.cpp:1076
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
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 
)
942{
943}

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