mirror of
https://github.com/mod-playerbots/azerothcore-wotlk.git
synced 2026-02-14 16:03:45 +00:00
feat(Core/ChatHandler/Conf): Flood Control Addon Messages (#12603)
* feat(Core/ChatHandler): Flood Control Addon Messages Original Closed PR by @Kitzunu https://github.com/azerothcore/azerothcore-wotlk/pull/11675 Cherrypicked TC: cherry-pick commit (TrinityCore/TrinityCore@5384fc1) cherry-pick commit (stoneharry/TrinityCore@a0629fc) Co-Authored-By: stoneharry 3818405+stoneharry@users.noreply.github.com Co-Authored-By: Shauren shauren.trinity@gmail.com Co-Authored-By: stoneharry <3818405+stoneharry@users.noreply.github.com> Co-Authored-By: Shauren <shauren.trinity@gmail.com> Co-Authored-By: Kitzunu <24550914+Kitzunu@users.noreply.github.com> * update: (pr): Review Response * update: (core): Chathandler No reason why this case should even exist. Previous or current. This cast is under two sided interations which will always lead to you being in a group of some sorts. there is literally zero sense having a above or equal to level 80 if statement here. * update (cleanup): Code Style suggestion per @Nefertumm Co-Authored-By: Angelo Venturini <nefertum.dev@protonmail.com> Co-authored-by: stoneharry <3818405+stoneharry@users.noreply.github.com> Co-authored-by: Shauren <shauren.trinity@gmail.com> Co-authored-by: Kitzunu <24550914+Kitzunu@users.noreply.github.com> Co-authored-by: Angelo Venturini <nefertum.dev@protonmail.com>
This commit is contained in:
@@ -26,34 +26,44 @@
|
||||
/*** FLOOD FILTER SYSTEM ***/
|
||||
/*********************************************************/
|
||||
|
||||
void Player::UpdateSpeakTime(uint32 specialMessageLimit)
|
||||
void Player::UpdateSpeakTime(ChatFloodThrottle::Index index)
|
||||
{
|
||||
// ignore chat spam protection for GMs in any mode
|
||||
if (!AccountMgr::IsPlayerAccount(GetSession()->GetSecurity()))
|
||||
return;
|
||||
|
||||
time_t current = GameTime::GetGameTime().count();
|
||||
if (m_speakTime > current)
|
||||
uint32 limit, delay;
|
||||
switch (index)
|
||||
{
|
||||
uint32 max_count = specialMessageLimit ? specialMessageLimit : sWorld->getIntConfig(CONFIG_CHATFLOOD_MESSAGE_COUNT);
|
||||
if (!max_count)
|
||||
return;
|
||||
|
||||
++m_speakCount;
|
||||
if (m_speakCount >= max_count)
|
||||
case ChatFloodThrottle::ADDON:
|
||||
limit = sWorld->getIntConfig(CONFIG_CHATFLOOD_ADDON_MESSAGE_COUNT);
|
||||
delay = sWorld->getIntConfig(CONFIG_CHATFLOOD_ADDON_MESSAGE_DELAY);
|
||||
break;
|
||||
case ChatFloodThrottle::REGULAR:
|
||||
limit = sWorld->getIntConfig(CONFIG_CHATFLOOD_MESSAGE_COUNT);
|
||||
delay = sWorld->getIntConfig(CONFIG_CHATFLOOD_MESSAGE_DELAY);
|
||||
[[fallthrough]];
|
||||
default:
|
||||
return;
|
||||
}
|
||||
time_t current = GameTime::GetGameTime().count();
|
||||
if (m_chatFloodData[index].Time > current)
|
||||
{
|
||||
++m_chatFloodData[index].Count;
|
||||
if (m_chatFloodData[index].Count >= limit)
|
||||
{
|
||||
// prevent overwrite mute time, if message send just before mutes set, for example.
|
||||
time_t new_mute = current + sWorld->getIntConfig(CONFIG_CHATFLOOD_MUTE_TIME);
|
||||
if (GetSession()->m_muteTime < new_mute)
|
||||
GetSession()->m_muteTime = new_mute;
|
||||
|
||||
m_speakCount = 0;
|
||||
m_chatFloodData[index].Count = 0;
|
||||
}
|
||||
}
|
||||
else
|
||||
m_speakCount = 1;
|
||||
m_chatFloodData[index].Count = 1;
|
||||
|
||||
m_speakTime = current + sWorld->getIntConfig(CONFIG_CHATFLOOD_MESSAGE_DELAY);
|
||||
m_chatFloodData[index].Time = current + delay;
|
||||
}
|
||||
|
||||
bool Player::CanSpeak() const
|
||||
|
||||
Reference in New Issue
Block a user