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:
M'Dic
2022-08-17 10:37:34 -04:00
committed by GitHub
parent b2e449fd15
commit 8b9541873a
9 changed files with 70 additions and 32 deletions

View File

@@ -194,10 +194,8 @@ void WorldSession::HandleMessagechatOpcode(WorldPacket& recvData)
return;
}
}
// LANG_ADDON should not be changed nor be affected by flood control
else
{
uint32 specialMessageLimit = 0;
// send in universal language if player in .gmon mode (ignore spell effects)
if (sender->IsGameMaster())
lang = LANG_UNIVERSAL;
@@ -218,20 +216,12 @@ void WorldSession::HandleMessagechatOpcode(WorldPacket& recvData)
// allow two side chat at group channel if two side group allowed
if (sWorld->getBoolConfig(CONFIG_ALLOW_TWO_SIDE_INTERACTION_GROUP))
lang = LANG_UNIVERSAL;
specialMessageLimit = 35;
break;
case CHAT_MSG_GUILD:
case CHAT_MSG_OFFICER:
// allow two side chat at guild channel if two side guild allowed
if (sWorld->getBoolConfig(CONFIG_ALLOW_TWO_SIDE_INTERACTION_GUILD))
lang = LANG_UNIVERSAL;
specialMessageLimit = 15;
break;
case CHAT_MSG_WHISPER:
if (sender->getLevel() >= 80)
specialMessageLimit = 15;
break;
}
}
@@ -242,7 +232,7 @@ void WorldSession::HandleMessagechatOpcode(WorldPacket& recvData)
}
if (type != CHAT_MSG_AFK && type != CHAT_MSG_DND)
sender->UpdateSpeakTime(specialMessageLimit);
sender->UpdateSpeakTime(lang == LANG_ADDON ? Player::ChatFloodThrottle::ADDON : Player::ChatFloodThrottle::REGULAR);
}
std::string to, channel, msg;
@@ -344,6 +334,11 @@ void WorldSession::HandleMessagechatOpcode(WorldPacket& recvData)
}
}
else
{
++_addonMessageReceiveCount;
}
sScriptMgr->OnBeforeSendChatMessage(_player, type, lang, msg);
switch (type)
@@ -726,7 +721,7 @@ void WorldSession::HandleTextEmoteOpcode(WorldPacket& recvData)
if (!GetPlayer()->IsAlive())
return;
GetPlayer()->UpdateSpeakTime();
GetPlayer()->UpdateSpeakTime(Player::ChatFloodThrottle::REGULAR);
if (!GetPlayer()->CanSpeak())
{