chore(Core/Chat): add Channel::ShouldAnnouncePlayer() method (#17819)
This commit is contained in:
committed by
GitHub
parent
d4931755ea
commit
86d704a514
@@ -198,8 +198,7 @@ void Channel::JoinChannel(Player* player, std::string const& pass)
|
|||||||
|
|
||||||
player->JoinedChannel(this);
|
player->JoinedChannel(this);
|
||||||
|
|
||||||
if (_announce && (!AccountMgr::IsGMAccount(player->GetSession()->GetSecurity()) ||
|
if (_announce && ShouldAnnouncePlayer(player))
|
||||||
!sWorld->getBoolConfig(CONFIG_SILENTLY_GM_JOIN_TO_CHANNEL)))
|
|
||||||
{
|
{
|
||||||
WorldPacket data;
|
WorldPacket data;
|
||||||
MakeJoined(&data, guid);
|
MakeJoined(&data, guid);
|
||||||
@@ -276,8 +275,7 @@ void Channel::LeaveChannel(Player* player, bool send)
|
|||||||
bool changeowner = playersStore[guid].IsOwner();
|
bool changeowner = playersStore[guid].IsOwner();
|
||||||
|
|
||||||
playersStore.erase(guid);
|
playersStore.erase(guid);
|
||||||
if (_announce && (!AccountMgr::IsGMAccount(player->GetSession()->GetSecurity()) ||
|
if (_announce && ShouldAnnouncePlayer(player))
|
||||||
!sWorld->getBoolConfig(CONFIG_SILENTLY_GM_JOIN_TO_CHANNEL)))
|
|
||||||
{
|
{
|
||||||
WorldPacket data;
|
WorldPacket data;
|
||||||
MakeLeft(&data, guid);
|
MakeLeft(&data, guid);
|
||||||
@@ -422,8 +420,6 @@ void Channel::KickOrBan(Player const* player, std::string const& badname, bool b
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool notify = !(AccountMgr::IsGMAccount(sec) && sWorld->getBoolConfig(CONFIG_SILENTLY_GM_JOIN_TO_CHANNEL));
|
|
||||||
|
|
||||||
if (ban)
|
if (ban)
|
||||||
{
|
{
|
||||||
if (!IsBanned(victim))
|
if (!IsBanned(victim))
|
||||||
@@ -431,7 +427,7 @@ void Channel::KickOrBan(Player const* player, std::string const& badname, bool b
|
|||||||
bannedStore[victim] = GameTime::GetGameTime().count() + CHANNEL_BAN_DURATION;
|
bannedStore[victim] = GameTime::GetGameTime().count() + CHANNEL_BAN_DURATION;
|
||||||
AddChannelBanToDB(victim, GameTime::GetGameTime().count() + CHANNEL_BAN_DURATION);
|
AddChannelBanToDB(victim, GameTime::GetGameTime().count() + CHANNEL_BAN_DURATION);
|
||||||
|
|
||||||
if (notify)
|
if (ShouldAnnouncePlayer(player))
|
||||||
{
|
{
|
||||||
WorldPacket data;
|
WorldPacket data;
|
||||||
MakePlayerBanned(&data, victim, good);
|
MakePlayerBanned(&data, victim, good);
|
||||||
@@ -439,7 +435,7 @@ void Channel::KickOrBan(Player const* player, std::string const& badname, bool b
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (notify)
|
else if (ShouldAnnouncePlayer(player))
|
||||||
{
|
{
|
||||||
WorldPacket data;
|
WorldPacket data;
|
||||||
MakePlayerKicked(&data, victim, good);
|
MakePlayerKicked(&data, victim, good);
|
||||||
@@ -896,18 +892,11 @@ void Channel::SetOwner(ObjectGuid 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);
|
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;
|
||||||
|
|
||||||
if (notify)
|
if (ShouldAnnouncePlayer(player))
|
||||||
{
|
{
|
||||||
MakeModeChange(&data, _ownerGUID, oldFlag);
|
MakeModeChange(&data, _ownerGUID, oldFlag);
|
||||||
SendToAll(&data);
|
SendToAll(&data);
|
||||||
@@ -915,7 +904,7 @@ void Channel::SetOwner(ObjectGuid guid, bool exclaim)
|
|||||||
|
|
||||||
FlagsNotify(pinfo.plrPtr);
|
FlagsNotify(pinfo.plrPtr);
|
||||||
|
|
||||||
if (exclaim && notify)
|
if (exclaim && ShouldAnnouncePlayer(player))
|
||||||
{
|
{
|
||||||
MakeOwnerChanged(&data, _ownerGUID);
|
MakeOwnerChanged(&data, _ownerGUID);
|
||||||
SendToAll(&data);
|
SendToAll(&data);
|
||||||
@@ -949,6 +938,11 @@ void Channel::SendToAllWatching(WorldPacket* data)
|
|||||||
(*i)->GetSession()->SendPacket(data);
|
(*i)->GetSession()->SendPacket(data);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool Channel::ShouldAnnouncePlayer(const Player* pPlayer) const
|
||||||
|
{
|
||||||
|
return !(AccountMgr::IsGMAccount(pPlayer->GetSession()->GetSecurity()) && sWorld->getBoolConfig(CONFIG_SILENTLY_GM_JOIN_TO_CHANNEL));
|
||||||
|
}
|
||||||
|
|
||||||
void Channel::Voice(ObjectGuid /*guid1*/, ObjectGuid /*guid2*/)
|
void Channel::Voice(ObjectGuid /*guid1*/, ObjectGuid /*guid2*/)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -271,6 +271,8 @@ private:
|
|||||||
void SendToOne(WorldPacket* data, ObjectGuid who);
|
void SendToOne(WorldPacket* data, ObjectGuid who);
|
||||||
void SendToAllWatching(WorldPacket* data);
|
void SendToAllWatching(WorldPacket* data);
|
||||||
|
|
||||||
|
bool ShouldAnnouncePlayer(const Player* pPlayer) const;
|
||||||
|
|
||||||
[[nodiscard]] bool IsOn(ObjectGuid who) const { return playersStore.find(who) != playersStore.end(); }
|
[[nodiscard]] bool IsOn(ObjectGuid who) const { return playersStore.find(who) != playersStore.end(); }
|
||||||
[[nodiscard]] bool IsBanned(ObjectGuid guid) const;
|
[[nodiscard]] bool IsBanned(ObjectGuid guid) const;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user