diff options
author | Naios <naios-dev@live.de> | 2015-10-12 21:26:18 +0200 |
---|---|---|
committer | Carbenium <carbenium@outlook.com> | 2015-11-06 23:46:53 +0100 |
commit | 441be76050d8463c8567c47fff88c10c88cc05be (patch) | |
tree | 09877c52b3be213286f3dd8da4861a1da1e57cc5 /src/server/game/Battlegrounds/BattlegroundQueue.cpp | |
parent | 39d29edf93574d0f133a66f44f059938c4de7a98 (diff) |
Merge pull request #15676 from ShinDarth/bg2
Core/Battlegrounds: implement even BG teams configuration
(cherry picked from commit f179c4180fec834c2d588f27994452649bdbe87c)
Diffstat (limited to 'src/server/game/Battlegrounds/BattlegroundQueue.cpp')
-rw-r--r-- | src/server/game/Battlegrounds/BattlegroundQueue.cpp | 29 |
1 files changed, 25 insertions, 4 deletions
diff --git a/src/server/game/Battlegrounds/BattlegroundQueue.cpp b/src/server/game/Battlegrounds/BattlegroundQueue.cpp index 8f459432d01..e02dde97658 100644 --- a/src/server/game/Battlegrounds/BattlegroundQueue.cpp +++ b/src/server/game/Battlegrounds/BattlegroundQueue.cpp @@ -497,24 +497,45 @@ void BattlegroundQueue::FillPlayersToBG(Battleground* bg, BattlegroundBracketId { int32 hordeFree = bg->GetFreeSlotsForTeam(HORDE); int32 aliFree = bg->GetFreeSlotsForTeam(ALLIANCE); + uint32 aliCount = m_QueuedGroups[bracket_id][BG_QUEUE_NORMAL_ALLIANCE].size(); + uint32 hordeCount = m_QueuedGroups[bracket_id][BG_QUEUE_NORMAL_HORDE].size(); + + // 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; + + hordeExtra = std::max(hordeExtra, 0); + aliExtra = std::max(aliExtra, 0); + + if (aliCount != hordeCount) + { + aliFree -= aliExtra; + hordeFree -= hordeExtra; + + aliFree = std::max(aliFree, 0); + hordeFree = std::max(hordeFree, 0); + } + } //iterator for iterating through bg queue GroupsQueueType::const_iterator Ali_itr = m_QueuedGroups[bracket_id][BG_QUEUE_NORMAL_ALLIANCE].begin(); //count of groups in queue - used to stop cycles - uint32 aliCount = m_QueuedGroups[bracket_id][BG_QUEUE_NORMAL_ALLIANCE].size(); + //index to queue which group is current uint32 aliIndex = 0; for (; aliIndex < aliCount && m_SelectionPools[TEAM_ALLIANCE].AddGroup((*Ali_itr), aliFree); aliIndex++) ++Ali_itr; //the same thing for horde GroupsQueueType::const_iterator Horde_itr = m_QueuedGroups[bracket_id][BG_QUEUE_NORMAL_HORDE].begin(); - uint32 hordeCount = m_QueuedGroups[bracket_id][BG_QUEUE_NORMAL_HORDE].size(); + uint32 hordeIndex = 0; for (; hordeIndex < hordeCount && m_SelectionPools[TEAM_HORDE].AddGroup((*Horde_itr), hordeFree); hordeIndex++) ++Horde_itr; //if ofc like BG queue invitation is set in config, then we are happy - if (sWorld->getIntConfig(CONFIG_BATTLEGROUND_INVITATION_TYPE) == 0) + if (sWorld->getIntConfig(CONFIG_BATTLEGROUND_INVITATION_TYPE) == BG_QUEUE_INVITATION_TYPE_NO_BALANCE) return; /* @@ -649,7 +670,7 @@ bool BattlegroundQueue::CheckNormalMatch(Battleground* /*bg_template*/, Battlegr uint32 j = TEAM_ALLIANCE; if (m_SelectionPools[TEAM_HORDE].GetPlayerCount() < m_SelectionPools[TEAM_ALLIANCE].GetPlayerCount()) j = TEAM_HORDE; - if (sWorld->getIntConfig(CONFIG_BATTLEGROUND_INVITATION_TYPE) != 0 + if (sWorld->getIntConfig(CONFIG_BATTLEGROUND_INVITATION_TYPE) != BG_QUEUE_INVITATION_TYPE_NO_BALANCE && m_SelectionPools[TEAM_HORDE].GetPlayerCount() >= minPlayers && m_SelectionPools[TEAM_ALLIANCE].GetPlayerCount() >= minPlayers) { //we will try to invite more groups to team with less players indexed by j |