aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorNaios <naios-dev@live.de>2015-10-12 21:26:18 +0200
committerCarbenium <carbenium@outlook.com>2015-11-06 23:46:53 +0100
commit441be76050d8463c8567c47fff88c10c88cc05be (patch)
tree09877c52b3be213286f3dd8da4861a1da1e57cc5 /src
parent39d29edf93574d0f133a66f44f059938c4de7a98 (diff)
Merge pull request #15676 from ShinDarth/bg2
Core/Battlegrounds: implement even BG teams configuration (cherry picked from commit f179c4180fec834c2d588f27994452649bdbe87c)
Diffstat (limited to 'src')
-rw-r--r--src/server/game/Battlegrounds/Battleground.cpp52
-rw-r--r--src/server/game/Battlegrounds/BattlegroundQueue.cpp29
-rw-r--r--src/server/game/Battlegrounds/BattlegroundQueue.h7
-rw-r--r--src/server/worldserver/worldserver.conf.dist1
4 files changed, 64 insertions, 25 deletions
diff --git a/src/server/game/Battlegrounds/Battleground.cpp b/src/server/game/Battlegrounds/Battleground.cpp
index fecb870549e..82e3aafc098 100644
--- a/src/server/game/Battlegrounds/Battleground.cpp
+++ b/src/server/game/Battlegrounds/Battleground.cpp
@@ -1251,48 +1251,58 @@ void Battleground::RemoveFromBGFreeSlotQueue()
// returns the number how many players can join battleground to MaxPlayersPerTeam
uint32 Battleground::GetFreeSlotsForTeam(uint32 Team) const
{
- // if BG is starting ... invite anyone
- if (GetStatus() == STATUS_WAIT_JOIN)
+ // if BG is starting and CONFIG_BATTLEGROUND_INVITATION_TYPE == BG_QUEUE_INVITATION_TYPE_NO_BALANCE, invite anyone
+ if (GetStatus() == STATUS_WAIT_JOIN && sWorld->getIntConfig(CONFIG_BATTLEGROUND_INVITATION_TYPE) == BG_QUEUE_INVITATION_TYPE_NO_BALANCE)
return (GetInvitedCount(Team) < GetMaxPlayersPerTeam()) ? GetMaxPlayersPerTeam() - GetInvitedCount(Team) : 0;
- // if BG is already started .. do not allow to join too much players of one faction
- uint32 otherTeam;
- uint32 otherIn;
+
+ // if BG is already started or CONFIG_BATTLEGROUND_INVITATION_TYPE != BG_QUEUE_INVITATION_TYPE_NO_BALANCE, do not allow to join too much players of one faction
+ uint32 otherTeamInvitedCount;
+ uint32 thisTeamInvitedCount;
+ uint32 otherTeamPlayersCount;
+ uint32 thisTeamPlayersCount;
+
if (Team == ALLIANCE)
{
- otherTeam = GetInvitedCount(HORDE);
- otherIn = GetPlayersCountByTeam(HORDE);
+ thisTeamInvitedCount = GetInvitedCount(ALLIANCE);
+ otherTeamInvitedCount = GetInvitedCount(HORDE);
+ thisTeamPlayersCount = GetPlayersCountByTeam(ALLIANCE);
+ otherTeamPlayersCount = GetPlayersCountByTeam(HORDE);
}
else
{
- otherTeam = GetInvitedCount(ALLIANCE);
- otherIn = GetPlayersCountByTeam(ALLIANCE);
+ thisTeamInvitedCount = GetInvitedCount(HORDE);
+ otherTeamInvitedCount = GetInvitedCount(ALLIANCE);
+ thisTeamPlayersCount = GetPlayersCountByTeam(HORDE);
+ otherTeamPlayersCount = GetPlayersCountByTeam(ALLIANCE);
}
- if (GetStatus() == STATUS_IN_PROGRESS)
+ if (GetStatus() == STATUS_IN_PROGRESS || GetStatus() == STATUS_WAIT_JOIN)
{
// difference based on ppl invited (not necessarily entered battle)
// default: allow 0
uint32 diff = 0;
- // allow join one person if the sides are equal (to fill up bg to minplayersperteam)
- if (otherTeam == GetInvitedCount(Team))
+
+ // allow join one person if the sides are equal (to fill up bg to minPlayerPerTeam)
+ if (otherTeamInvitedCount == thisTeamInvitedCount)
diff = 1;
// allow join more ppl if the other side has more players
- else if (otherTeam > GetInvitedCount(Team))
- diff = otherTeam - GetInvitedCount(Team);
+ else if (otherTeamInvitedCount > thisTeamInvitedCount)
+ diff = otherTeamInvitedCount - thisTeamInvitedCount;
// difference based on max players per team (don't allow inviting more)
- uint32 diff2 = (GetInvitedCount(Team) < GetMaxPlayersPerTeam()) ? GetMaxPlayersPerTeam() - GetInvitedCount(Team) : 0;
+ uint32 diff2 = (thisTeamInvitedCount < GetMaxPlayersPerTeam()) ? GetMaxPlayersPerTeam() - thisTeamInvitedCount : 0;
+
// difference based on players who already entered
// default: allow 0
uint32 diff3 = 0;
- // allow join one person if the sides are equal (to fill up bg minplayersperteam)
- if (otherIn == GetPlayersCountByTeam(Team))
+ // allow join one person if the sides are equal (to fill up bg minPlayerPerTeam)
+ if (otherTeamPlayersCount == thisTeamPlayersCount)
diff3 = 1;
// allow join more ppl if the other side has more players
- else if (otherIn > GetPlayersCountByTeam(Team))
- diff3 = otherIn - GetPlayersCountByTeam(Team);
+ else if (otherTeamPlayersCount > thisTeamPlayersCount)
+ diff3 = otherTeamPlayersCount - thisTeamPlayersCount;
// or other side has less than minPlayersPerTeam
- else if (GetInvitedCount(Team) <= GetMinPlayersPerTeam())
- diff3 = GetMinPlayersPerTeam() - GetInvitedCount(Team) + 1;
+ else if (thisTeamInvitedCount <= GetMinPlayersPerTeam())
+ diff3 = GetMinPlayersPerTeam() - thisTeamInvitedCount + 1;
// return the minimum of the 3 differences
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
diff --git a/src/server/game/Battlegrounds/BattlegroundQueue.h b/src/server/game/Battlegrounds/BattlegroundQueue.h
index eb225250a56..2a64e1cb324 100644
--- a/src/server/game/Battlegrounds/BattlegroundQueue.h
+++ b/src/server/game/Battlegrounds/BattlegroundQueue.h
@@ -64,6 +64,13 @@ enum BattlegroundQueueGroupTypes
};
#define BG_QUEUE_GROUP_TYPES_COUNT 4
+enum BattlegroundQueueInvitationType
+{
+ BG_QUEUE_INVITATION_TYPE_NO_BALANCE = 0, // no balance: N+M vs N players
+ BG_QUEUE_INVITATION_TYPE_BALANCED = 1, // teams balanced: N+1 vs N players
+ BG_QUEUE_INVITATION_TYPE_EVEN = 2 // teams even: N vs N players
+};
+
class Battleground;
class BattlegroundQueue
{
diff --git a/src/server/worldserver/worldserver.conf.dist b/src/server/worldserver/worldserver.conf.dist
index 65daf1480ca..1229ccd2d93 100644
--- a/src/server/worldserver/worldserver.conf.dist
+++ b/src/server/worldserver/worldserver.conf.dist
@@ -2250,6 +2250,7 @@ Battleground.StoreStatistics.Enable = 0
# Don't bother with balance)
# 1 - (Experimental, Don't allow to invite much more players
# of one faction)
+# 2 - (Experimental, Try to have even teams)
Battleground.InvitationType = 0