From b76ea116851bae7084d36091fa1fa430de9b5dda Mon Sep 17 00:00:00 2001 From: ShinDarth Date: Tue, 13 Oct 2015 17:39:12 +0200 Subject: Core/BG: Improved https://github.com/TrinityCore/TrinityCore/commit/d7cb84f6cddb56bc818b2bf30d3318d052039540 - Handle case when some players leave or InvitationType changes while running - Add some comments --- .../game/Battlegrounds/BattlegroundQueue.cpp | 26 +++++++++++++--------- 1 file changed, 16 insertions(+), 10 deletions(-) (limited to 'src') diff --git a/src/server/game/Battlegrounds/BattlegroundQueue.cpp b/src/server/game/Battlegrounds/BattlegroundQueue.cpp index 6fd25246690..162122ab4db 100644 --- a/src/server/game/Battlegrounds/BattlegroundQueue.cpp +++ b/src/server/game/Battlegrounds/BattlegroundQueue.cpp @@ -503,19 +503,25 @@ void BattlegroundQueue::FillPlayersToBG(Battleground* bg, BattlegroundBracketId // try to get even teams if (sWorld->getIntConfig(CONFIG_BATTLEGROUND_INVITATION_TYPE) == BG_QUEUE_INVITATION_TYPE_EVEN) { - int32 hordeExtra = hordeCount - aliCount; - int32 aliExtra = aliCount - hordeCount; + // check if the teams are even + if (hordeFree == 1 && aliFree == 1) + { + // if we are here, the teams have the same amount of players + // then we have to allow to join the same amount of players + int32 hordeExtra = hordeCount - aliCount; + int32 aliExtra = aliCount - hordeCount; - hordeExtra = std::max(hordeExtra, 0); - aliExtra = std::max(aliExtra, 0); + hordeExtra = std::max(hordeExtra, 0); + aliExtra = std::max(aliExtra, 0); - if (aliCount != hordeCount) - { - aliFree -= aliExtra; - hordeFree -= hordeExtra; + if (aliCount != hordeCount) + { + aliFree -= aliExtra; + hordeFree -= hordeExtra; - aliFree = std::max(aliFree, 0); - hordeFree = std::max(hordeFree, 0); + aliFree = std::max(aliFree, 0); + hordeFree = std::max(hordeFree, 0); + } } } -- cgit v1.2.3