mirror of
https://github.com/mod-playerbots/azerothcore-wotlk.git
synced 2026-01-24 14:16:31 +00:00
fix(Core/Chat): Channel exploit (#2298)
This commit is contained in:
@@ -17,6 +17,7 @@ Channel::Channel(std::string const& name, uint32 channelId, uint32 channelDBId,
|
||||
_announce(announce),
|
||||
_ownership(ownership),
|
||||
_IsSaved(false),
|
||||
_isOwnerGM(false),
|
||||
_flags(0),
|
||||
_channelId(channelId),
|
||||
_channelDBId(channelDBId),
|
||||
@@ -212,6 +213,8 @@ void Channel::JoinChannel(Player* player, std::string const& pass)
|
||||
|
||||
JoinNotify(player);
|
||||
|
||||
playersStore[guid].SetOwnerGM(AccountMgr::IsGMAccount(player->GetSession()->GetSecurity()));
|
||||
|
||||
// Custom channel handling
|
||||
if (!IsConstant())
|
||||
{
|
||||
@@ -226,8 +229,12 @@ void Channel::JoinChannel(Player* player, std::string const& pass)
|
||||
}
|
||||
|
||||
// If the channel has no owner yet and ownership is allowed, set the new owner.
|
||||
if (!_ownerGUID && _ownership)
|
||||
// If the channel owner is a GM and the config SilentGMJoinChannel is enabled, set the new owner
|
||||
if ((!_ownerGUID || (_isOwnerGM && sWorld->getBoolConfig(CONFIG_SILENTLY_GM_JOIN_TO_CHANNEL))) && _ownership)
|
||||
{
|
||||
_isOwnerGM = playersStore[guid].IsOwnerGM();
|
||||
SetOwner(guid, false);
|
||||
}
|
||||
|
||||
if (_channelRights.flags & CHANNEL_RIGHT_CANT_SPEAK)
|
||||
playersStore[guid].SetMuted(true);
|
||||
@@ -285,10 +292,15 @@ void Channel::LeaveChannel(Player* player, bool send)
|
||||
for (Channel::PlayerContainer::const_iterator itr = playersStore.begin(); itr != playersStore.end(); ++itr)
|
||||
{
|
||||
newowner = itr->second.player;
|
||||
if (AccountMgr::IsGMAccount(itr->second.plrPtr->GetSession()->GetSecurity()))
|
||||
_isOwnerGM = true;
|
||||
else
|
||||
_isOwnerGM = false;
|
||||
if (!itr->second.plrPtr->GetSession()->GetSecurity())
|
||||
break;
|
||||
}
|
||||
SetOwner(newowner);
|
||||
// if the new owner is invisible gm, set flag to automatically choose a new owner
|
||||
}
|
||||
else
|
||||
SetOwner(0);
|
||||
@@ -911,13 +923,26 @@ void Channel::SetOwner(uint64 guid, bool exclaim)
|
||||
uint8 oldFlag = pinfo.flags;
|
||||
pinfo.SetOwner(true);
|
||||
|
||||
bool notify = true;
|
||||
Player* player = ObjectAccessor::FindPlayer(_ownerGUID);
|
||||
|
||||
if (player)
|
||||
{
|
||||
uint32 sec = player->GetSession()->GetSecurity();
|
||||
notify = !(AccountMgr::IsGMAccount(sec) && sWorld->getBoolConfig(CONFIG_SILENTLY_GM_JOIN_TO_CHANNEL));
|
||||
}
|
||||
|
||||
WorldPacket data;
|
||||
MakeModeChange(&data, _ownerGUID, oldFlag);
|
||||
SendToAll(&data);
|
||||
|
||||
if (notify)
|
||||
{
|
||||
MakeModeChange(&data, _ownerGUID, oldFlag);
|
||||
SendToAll(&data);
|
||||
}
|
||||
|
||||
FlagsNotify(pinfo.plrPtr);
|
||||
|
||||
if (exclaim)
|
||||
if (exclaim && notify)
|
||||
{
|
||||
MakeOwnerChanged(&data, _ownerGUID);
|
||||
SendToAll(&data);
|
||||
|
||||
Reference in New Issue
Block a user