From d940a8560d6e4114381c3eae0d281c5cbe82e847 Mon Sep 17 00:00:00 2001 From: Kargatum Date: Wed, 7 Sep 2022 07:20:54 +0700 Subject: [PATCH] fix(Core/BGQueue): correct start match logic (#12823) cherrypick https://github.com/WarheadCore/WarheadBand/commit/1a3cd2942a88ef64152afeba4d9594237aa962d1 --- .../game/Battlegrounds/BattlegroundQueue.cpp | 21 +++++++++++-------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/src/server/game/Battlegrounds/BattlegroundQueue.cpp b/src/server/game/Battlegrounds/BattlegroundQueue.cpp index 43f9b7320..ebb4ad8ec 100644 --- a/src/server/game/Battlegrounds/BattlegroundQueue.cpp +++ b/src/server/game/Battlegrounds/BattlegroundQueue.cpp @@ -573,10 +573,18 @@ bool BattlegroundQueue::CheckPremadeMatch(BattlegroundBracketId bracket_id, uint // this method tries to create battleground or arena with MinPlayersPerTeam against MinPlayersPerTeam bool BattlegroundQueue::CheckNormalMatch(Battleground* bgTemplate, BattlegroundBracketId bracket_id, uint32 minPlayers, uint32 maxPlayers) { - if (sScriptMgr->IsCheckNormalMatch(this, bgTemplate, bracket_id, minPlayers, maxPlayers)) + auto CanStartMatch = [this, bgTemplate, minPlayers]() { - return true; - } + //allow 1v0 if debug bg + if (sBattlegroundMgr->isTesting() && bgTemplate->isBattleground() && (m_SelectionPools[TEAM_ALLIANCE].GetPlayerCount() || m_SelectionPools[TEAM_HORDE].GetPlayerCount())) + return true; + + //return true if there are enough players in selection pools - enable to work .debug bg command correctly + return m_SelectionPools[TEAM_ALLIANCE].GetPlayerCount() >= minPlayers && m_SelectionPools[TEAM_HORDE].GetPlayerCount() >= minPlayers; + }; + + if (sScriptMgr->IsCheckNormalMatch(this, bgTemplate, bracket_id, minPlayers, maxPlayers)) + return CanStartMatch(); GroupsQueueType::const_iterator itr_team[PVP_TEAMS_COUNT]; for (uint32 i = 0; i < PVP_TEAMS_COUNT; i++) @@ -615,12 +623,7 @@ bool BattlegroundQueue::CheckNormalMatch(Battleground* bgTemplate, BattlegroundB return false; } - //allow 1v0 if debug bg - if (sBattlegroundMgr->isTesting() && bgTemplate->isBattleground() && (m_SelectionPools[TEAM_ALLIANCE].GetPlayerCount() || m_SelectionPools[TEAM_HORDE].GetPlayerCount())) - return true; - - //return true if there are enough players in selection pools - enable to work .debug bg command correctly - return m_SelectionPools[TEAM_ALLIANCE].GetPlayerCount() >= minPlayers && m_SelectionPools[TEAM_HORDE].GetPlayerCount() >= minPlayers; + return CanStartMatch(); } // this method will check if we can invite players to same faction skirmish match