mirror of
https://github.com/liyunfan1223/azerothcore-wotlk.git
synced 2026-08-08 15:58:04 +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),
|
_announce(announce),
|
||||||
_ownership(ownership),
|
_ownership(ownership),
|
||||||
_IsSaved(false),
|
_IsSaved(false),
|
||||||
|
_isOwnerGM(false),
|
||||||
_flags(0),
|
_flags(0),
|
||||||
_channelId(channelId),
|
_channelId(channelId),
|
||||||
_channelDBId(channelDBId),
|
_channelDBId(channelDBId),
|
||||||
@@ -212,6 +213,8 @@ void Channel::JoinChannel(Player* player, std::string const& pass)
|
|||||||
|
|
||||||
JoinNotify(player);
|
JoinNotify(player);
|
||||||
|
|
||||||
|
playersStore[guid].SetOwnerGM(AccountMgr::IsGMAccount(player->GetSession()->GetSecurity()));
|
||||||
|
|
||||||
// Custom channel handling
|
// Custom channel handling
|
||||||
if (!IsConstant())
|
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 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);
|
SetOwner(guid, false);
|
||||||
|
}
|
||||||
|
|
||||||
if (_channelRights.flags & CHANNEL_RIGHT_CANT_SPEAK)
|
if (_channelRights.flags & CHANNEL_RIGHT_CANT_SPEAK)
|
||||||
playersStore[guid].SetMuted(true);
|
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)
|
for (Channel::PlayerContainer::const_iterator itr = playersStore.begin(); itr != playersStore.end(); ++itr)
|
||||||
{
|
{
|
||||||
newowner = itr->second.player;
|
newowner = itr->second.player;
|
||||||
|
if (AccountMgr::IsGMAccount(itr->second.plrPtr->GetSession()->GetSecurity()))
|
||||||
|
_isOwnerGM = true;
|
||||||
|
else
|
||||||
|
_isOwnerGM = false;
|
||||||
if (!itr->second.plrPtr->GetSession()->GetSecurity())
|
if (!itr->second.plrPtr->GetSession()->GetSecurity())
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
SetOwner(newowner);
|
SetOwner(newowner);
|
||||||
|
// if the new owner is invisible gm, set flag to automatically choose a new owner
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
SetOwner(0);
|
SetOwner(0);
|
||||||
@@ -911,13 +923,26 @@ void Channel::SetOwner(uint64 guid, bool exclaim)
|
|||||||
uint8 oldFlag = pinfo.flags;
|
uint8 oldFlag = pinfo.flags;
|
||||||
pinfo.SetOwner(true);
|
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;
|
WorldPacket data;
|
||||||
MakeModeChange(&data, _ownerGUID, oldFlag);
|
|
||||||
SendToAll(&data);
|
if (notify)
|
||||||
|
{
|
||||||
|
MakeModeChange(&data, _ownerGUID, oldFlag);
|
||||||
|
SendToAll(&data);
|
||||||
|
}
|
||||||
|
|
||||||
FlagsNotify(pinfo.plrPtr);
|
FlagsNotify(pinfo.plrPtr);
|
||||||
|
|
||||||
if (exclaim)
|
if (exclaim && notify)
|
||||||
{
|
{
|
||||||
MakeOwnerChanged(&data, _ownerGUID);
|
MakeOwnerChanged(&data, _ownerGUID);
|
||||||
SendToAll(&data);
|
SendToAll(&data);
|
||||||
|
|||||||
@@ -150,6 +150,8 @@ class Channel
|
|||||||
if (state) flags |= MEMBER_FLAG_OWNER;
|
if (state) flags |= MEMBER_FLAG_OWNER;
|
||||||
else flags &= ~MEMBER_FLAG_OWNER;
|
else flags &= ~MEMBER_FLAG_OWNER;
|
||||||
}
|
}
|
||||||
|
bool IsOwnerGM() const { return _gmStatus; }
|
||||||
|
void SetOwnerGM(bool on) { _gmStatus = on; }
|
||||||
bool IsModerator() const { return flags & MEMBER_FLAG_MODERATOR; }
|
bool IsModerator() const { return flags & MEMBER_FLAG_MODERATOR; }
|
||||||
void SetModerator(bool state)
|
void SetModerator(bool state)
|
||||||
{
|
{
|
||||||
@@ -172,6 +174,8 @@ class Channel
|
|||||||
else
|
else
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
private:
|
||||||
|
bool _gmStatus = false;
|
||||||
};
|
};
|
||||||
|
|
||||||
public:
|
public:
|
||||||
@@ -315,6 +319,7 @@ class Channel
|
|||||||
bool _announce;
|
bool _announce;
|
||||||
bool _ownership;
|
bool _ownership;
|
||||||
bool _IsSaved;
|
bool _IsSaved;
|
||||||
|
bool _isOwnerGM;
|
||||||
uint8 _flags;
|
uint8 _flags;
|
||||||
uint32 _channelId;
|
uint32 _channelId;
|
||||||
uint32 _channelDBId;
|
uint32 _channelDBId;
|
||||||
|
|||||||
Reference in New Issue
Block a user