From 12274854122078a2da87af1518d4fb10ccf4e4cb Mon Sep 17 00:00:00 2001 From: WiZZy Date: Sun, 6 Oct 2019 17:34:46 +0000 Subject: [PATCH] fix(Core/Battleground): Improving the Anti-Spam BG Queue Announcer (#2299) --- .../game/Battlegrounds/BattlegroundQueue.cpp | 25 +++++++------------ 1 file changed, 9 insertions(+), 16 deletions(-) diff --git a/src/server/game/Battlegrounds/BattlegroundQueue.cpp b/src/server/game/Battlegrounds/BattlegroundQueue.cpp index 406ce1a87..63a729ca6 100644 --- a/src/server/game/Battlegrounds/BattlegroundQueue.cpp +++ b/src/server/game/Battlegrounds/BattlegroundQueue.cpp @@ -19,12 +19,7 @@ #include "ScriptMgr.h" #include -struct BGSpamProtectionS -{ - uint32 last_queue = 0; // CHAT DISABLED BY DEFAULT -}; - -std::unordered_map BGSpamProtection; +std::unordered_map BGSpamProtection; /*********************************************************/ /*** BATTLEGROUND QUEUE SYSTEM ***/ @@ -1031,17 +1026,15 @@ void BattlegroundQueue::SendMessageQueue(Player* leader, Battleground* bg, PvPDi } else if (!bg->isArena()) // Show queue status to server (when joining battleground queue) { - if (BGSpamProtection[leader->GetGUID()].last_queue == 0) + auto searchGUID = BGSpamProtection.find(leader->GetGUID()); + + if (searchGUID == BGSpamProtection.end()) + BGSpamProtection[leader->GetGUID()] = 0; // Leader GUID not found, initialize with 0 + + if (sWorld->GetGameTime() - BGSpamProtection[leader->GetGUID()] >= 30) { - BGSpamProtection[leader->GetGUID()].last_queue = sWorld->GetGameTime(); - sWorld->SendWorldText(LANG_BG_QUEUE_ANNOUNCE_WORLD, bgName, q_min_level, q_max_level, - qAlliance + qHorde, MaxPlayers); - } - else if (sWorld->GetGameTime() - BGSpamProtection[leader->GetGUID()].last_queue >= 30) - { - BGSpamProtection[leader->GetGUID()].last_queue = 0; - sWorld->SendWorldText(LANG_BG_QUEUE_ANNOUNCE_WORLD, bgName, q_min_level, q_max_level, - qAlliance + qHorde, MaxPlayers); + BGSpamProtection[leader->GetGUID()] = sWorld->GetGameTime(); + sWorld->SendWorldText(LANG_BG_QUEUE_ANNOUNCE_WORLD, bgName, q_min_level, q_max_level, qAlliance + qHorde, MaxPlayers); } } }