Merge pull request #508 from atidot3/extractregexfix

Optimised ExtractAllQuestIds ExtractAllItemIds
This commit is contained in:
Yunfan Li
2024-09-07 00:38:51 +08:00
committed by GitHub
3 changed files with 59 additions and 58 deletions

View File

@@ -1005,26 +1005,25 @@ void PlayerbotAI::HandleBotOutgoingPacket(WorldPacket const& packet)
if (lang == LANG_ADDON)
return;
// 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 (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;