From ebec48e6fd931de83381aa5c161a39850fa26642 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Francesco=20Borz=C3=AC?= Date: Sun, 14 Jun 2020 23:12:24 +0200 Subject: [PATCH] fix(Core/Battleground): fix queue issue (#3116) * Remove useless code that was only causing issue to the BG queue * Prevent new Battlegrounds to start if there are already other Battlegrounds that have free slots Co-authored-by Yehonal --- src/server/game/Battlegrounds/BattlegroundMgr.cpp | 11 +++++------ src/server/game/Battlegrounds/BattlegroundQueue.cpp | 7 ++----- src/server/game/Battlegrounds/BattlegroundQueue.h | 2 +- 3 files changed, 8 insertions(+), 12 deletions(-) diff --git a/src/server/game/Battlegrounds/BattlegroundMgr.cpp b/src/server/game/Battlegrounds/BattlegroundMgr.cpp index 783df4739..a12237bc1 100644 --- a/src/server/game/Battlegrounds/BattlegroundMgr.cpp +++ b/src/server/game/Battlegrounds/BattlegroundMgr.cpp @@ -106,7 +106,7 @@ void BattlegroundMgr::Update(uint32 diff) uint32 arenaRatedTeamId = scheduled[i] >> 32; BattlegroundQueueTypeId bgQueueTypeId = BattlegroundQueueTypeId(scheduled[i] >> 16 & 255); BattlegroundBracketId bracket_id = BattlegroundBracketId(scheduled[i] & 255); - m_BattlegroundQueues[bgQueueTypeId].BattlegroundQueueUpdate(bracket_id, 0x03, true, arenaRatedTeamId); // pussywizard: looking for opponents only for this team + m_BattlegroundQueues[bgQueueTypeId].BattlegroundQueueUpdate(bracket_id, true, arenaRatedTeamId); // pussywizard: looking for opponents only for this team } } @@ -116,14 +116,13 @@ void BattlegroundMgr::Update(uint32 diff) // for rated arenas for (uint32 qtype = BATTLEGROUND_QUEUE_2v2; qtype < MAX_BATTLEGROUND_QUEUE_TYPES; ++qtype) for (uint32 bracket = BG_BRACKET_ID_FIRST; bracket < MAX_BATTLEGROUND_BRACKETS; ++bracket) - m_BattlegroundQueues[qtype].BattlegroundQueueUpdate(BattlegroundBracketId(bracket), 0x03, true, 0); // pussywizard: 0 for rated means looking for opponents for every team + m_BattlegroundQueues[qtype].BattlegroundQueueUpdate(BattlegroundBracketId(bracket), true, 0); // pussywizard: 0 for rated means looking for opponents for every team // for battlegrounds and not rated arenas // in first loop try to fill already running battlegrounds, then in a second loop try to create new battlegrounds - for (uint8 action = 1; action <= 2; ++action) - for (uint32 qtype = BATTLEGROUND_QUEUE_AV; qtype < MAX_BATTLEGROUND_QUEUE_TYPES; ++qtype) - for (uint32 bracket = BG_BRACKET_ID_FIRST; bracket < MAX_BATTLEGROUND_BRACKETS; ++bracket) - m_BattlegroundQueues[qtype].BattlegroundQueueUpdate(BattlegroundBracketId(bracket), action, false, 0); + for (uint32 qtype = BATTLEGROUND_QUEUE_AV; qtype < MAX_BATTLEGROUND_QUEUE_TYPES; ++qtype) + for (uint32 bracket = BG_BRACKET_ID_FIRST; bracket < MAX_BATTLEGROUND_BRACKETS; ++bracket) + m_BattlegroundQueues[qtype].BattlegroundQueueUpdate(BattlegroundBracketId(bracket), false, 0); m_NextPeriodicQueueUpdateTime = 5*IN_MILLISECONDS; } diff --git a/src/server/game/Battlegrounds/BattlegroundQueue.cpp b/src/server/game/Battlegrounds/BattlegroundQueue.cpp index 47a8632be..6db6cc82e 100644 --- a/src/server/game/Battlegrounds/BattlegroundQueue.cpp +++ b/src/server/game/Battlegrounds/BattlegroundQueue.cpp @@ -670,7 +670,7 @@ void BattlegroundQueue::UpdateEvents(uint32 diff) struct BgEmptinessComp { bool operator()(Battleground* const& bg1, Battleground* const& bg2) const { return ((float)bg1->GetMaxFreeSlots() / (float)bg1->GetMaxPlayersPerTeam()) > ((float)bg2->GetMaxFreeSlots() / (float)bg2->GetMaxPlayersPerTeam()); } }; typedef std::set BattlegroundNeedSet; -void BattlegroundQueue::BattlegroundQueueUpdate(BattlegroundBracketId bracket_id, uint8 actionMask, bool isRated, uint32 arenaRatedTeamId) +void BattlegroundQueue::BattlegroundQueueUpdate(BattlegroundBracketId bracket_id, bool isRated, uint32 arenaRatedTeamId) { // if no players in queue - do nothing if (IsAllQueuesEmpty(bracket_id)) @@ -685,7 +685,7 @@ void BattlegroundQueue::BattlegroundQueueUpdate(BattlegroundBracketId bracket_id return; // battlegrounds with free slots should be populated first using players in queue - if ((actionMask & 0x01) && !BattlegroundMgr::IsArenaType(m_bgTypeId)) + if (!BattlegroundMgr::IsArenaType(m_bgTypeId)) { const BattlegroundContainer& bgList = sBattlegroundMgr->GetBattlegroundList(); BattlegroundNeedSet bgsToCheck; @@ -722,9 +722,6 @@ void BattlegroundQueue::BattlegroundQueueUpdate(BattlegroundBracketId bracket_id // finished iterating through battlegrounds with free slots, maybe we need to create a new bg - if ((actionMask & 0x02) == 0) - return; - // get min and max players per team uint32 MinPlayersPerTeam = bg_template->GetMinPlayersPerTeam(); uint32 MaxPlayersPerTeam = bg_template->GetMaxPlayersPerTeam(); diff --git a/src/server/game/Battlegrounds/BattlegroundQueue.h b/src/server/game/Battlegrounds/BattlegroundQueue.h index dbb5eeda8..64256051c 100644 --- a/src/server/game/Battlegrounds/BattlegroundQueue.h +++ b/src/server/game/Battlegrounds/BattlegroundQueue.h @@ -55,7 +55,7 @@ class BattlegroundQueue BattlegroundQueue(); ~BattlegroundQueue(); - void BattlegroundQueueUpdate(BattlegroundBracketId bracket_id, uint8 actionMask, bool isRated, uint32 arenaRatedTeamId); + void BattlegroundQueueUpdate(BattlegroundBracketId bracket_id, bool isRated, uint32 arenaRatedTeamId); void UpdateEvents(uint32 diff); void FillPlayersToBG(Battleground* bg, const int32 aliFree, const int32 hordeFree, BattlegroundBracketId bracket_id);