[Talk] Disable ExtractAllItemIds for heavy regex

This commit is contained in:
Yunfan Li
2024-08-19 18:47:08 +08:00
parent 1700a20c89
commit 2c7cef0dc2
3 changed files with 40 additions and 32 deletions

View File

@@ -1002,23 +1002,26 @@ void PlayerbotAI::HandleBotOutgoingPacket(WorldPacket const& packet)
if (lang == LANG_ADDON)
return;
if (message.starts_with(sPlayerbotAIConfig->toxicLinksPrefix)
&& (GetChatHelper()->ExtractAllItemIds(message).size() > 0 || GetChatHelper()->ExtractAllQuestIds(message).size() > 0)
&& sPlayerbotAIConfig->toxicLinksRepliesChance)
{
if (urand(0, 50) > 0 || urand(1, 100) > sPlayerbotAIConfig->toxicLinksRepliesChance)
{
return;
}
}
else if ((GetChatHelper()->ExtractAllItemIds(message).count(19019) && sPlayerbotAIConfig->thunderfuryRepliesChance))
{
if (urand(0, 60) > 0 || urand(1, 100) > sPlayerbotAIConfig->thunderfuryRepliesChance)
{
return;
}
}
else
// Disable since ExtractAllItemIds bad performance
// if (message.starts_with(sPlayerbotAIConfig->toxicLinksPrefix) &&
// (GetChatHelper()->ExtractAllItemIds(message).size() > 0 ||
// GetChatHelper()->ExtractAllQuestIds(message).size() > 0) &&
// sPlayerbotAIConfig->toxicLinksRepliesChance)
// {
// if (urand(0, 50) > 0 || urand(1, 100) > sPlayerbotAIConfig->toxicLinksRepliesChance)
// {
// return;
// }
// }
// else if ((GetChatHelper()->ExtractAllItemIds(message).count(19019) &&
// sPlayerbotAIConfig->thunderfuryRepliesChance))
// {
// if (urand(0, 60) > 0 || urand(1, 100) > sPlayerbotAIConfig->thunderfuryRepliesChance)
// {
// return;
// }
// }
// else
{
if (isFromFreeBot && urand(0, 20))
return;
@@ -2782,7 +2785,7 @@ bool PlayerbotAI::CanCastSpell(uint32 spellid, Unit* target, bool checkHasSpell,
// break;
// }
// }
if (target->IsImmunedToSpell(spellInfo))
{
if (!sPlayerbotAIConfig->logInGroupOnly || (bot->GetGroup() && HasRealPlayerMaster()))