feat(Core/Opcodes): Implement CMSG_CHANNEL_MODERATE (#4021)

* Core/Opcodes: Implement CMSG_CHANNEL_MODERATE

* Cleanup, prettify

* fix build

* whitespaces
This commit is contained in:
FALL1N1
2021-01-18 20:37:50 +02:00
committed by GitHub
parent 72f2a7706e
commit 0181b73bc2
8 changed files with 86 additions and 4 deletions

View File

@@ -1258,3 +1258,54 @@ void Channel::RemoveWatching(Player* p)
if (itr != playersWatchingStore.end())
playersWatchingStore.erase(itr);
}
void Channel::ToggleModeration(Player* player)
{
uint64 guid = player->GetGUIDLow();
if (!IsOn(guid))
{
WorldPacket data;
MakeNotMember(&data);
SendToOne(&data, guid);
return;
}
const uint32 level = sWorld->getIntConfig(CONFIG_GM_LEVEL_CHANNEL_MODERATION);
const bool gm = (level && player->GetSession()->GetSecurity() >= level);
if (!playersStore[guid].IsModerator() && !gm)
{
WorldPacket data;
MakeNotModerator(&data);
SendToOne(&data, guid);
return;
}
// toggle channel moderation
_moderation = !_moderation;
WorldPacket data;
if (_moderation)
{
MakeModerationOn(&data, guid);
}
else
{
MakeModerationOff(&data, guid);
}
SendToAll(&data);
}
void Channel::MakeModerationOn(WorldPacket* data, uint64 guid)
{
MakeNotifyPacket(data, CHAT_MODERATION_ON_NOTICE);
*data << uint64(guid);
}
void Channel::MakeModerationOff(WorldPacket* data, uint64 guid)
{
MakeNotifyPacket(data, CHAT_MODERATION_OFF_NOTICE);
*data << uint64(guid);
}