Merge pull request #15676 from ShinDarth/bg2
Core/Battlegrounds: implement even BG teams configuration
This commit is contained in:
commit
f179c4180f
4 files changed
+64
-25
No files matched your search
@@ -1166,48 +1166,58 @@ void Battleground::RemoveFromBGFreeSlotQueue()
|
|||||||
// returns the number how many players can join battleground to MaxPlayersPerTeam
|
// returns the number how many players can join battleground to MaxPlayersPerTeam
|
||||||
uint32 Battleground::GetFreeSlotsForTeam(uint32 Team) const
|
uint32 Battleground::GetFreeSlotsForTeam(uint32 Team) const
|
||||||
{
|
{
|
||||||
// if BG is starting ... invite anyone
|
// if BG is starting and CONFIG_BATTLEGROUND_INVITATION_TYPE == BG_QUEUE_INVITATION_TYPE_NO_BALANCE, invite anyone
|
||||||
if (GetStatus() == STATUS_WAIT_JOIN)
|
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;
|
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;
|
// 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 otherIn;
|
uint32 otherTeamInvitedCount;
|
||||||
|
uint32 thisTeamInvitedCount;
|
||||||
|
uint32 otherTeamPlayersCount;
|
||||||
|
uint32 thisTeamPlayersCount;
|
||||||
|
|
||||||
if (Team == ALLIANCE)
|
if (Team == ALLIANCE)
|
||||||
{
|
{
|
||||||
otherTeam = GetInvitedCount(HORDE);
|
thisTeamInvitedCount = GetInvitedCount(ALLIANCE);
|
||||||
otherIn = GetPlayersCountByTeam(HORDE);
|
otherTeamInvitedCount = GetInvitedCount(HORDE);
|
||||||
|
thisTeamPlayersCount = GetPlayersCountByTeam(ALLIANCE);
|
||||||
|
otherTeamPlayersCount = GetPlayersCountByTeam(HORDE);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
otherTeam = GetInvitedCount(ALLIANCE);
|
thisTeamInvitedCount = GetInvitedCount(HORDE);
|
||||||
otherIn = GetPlayersCountByTeam(ALLIANCE);
|
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)
|
// difference based on ppl invited (not necessarily entered battle)
|
||||||
// default: allow 0
|
// default: allow 0
|
||||||
uint32 diff = 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;
|
diff = 1;
|
||||||
// allow join more ppl if the other side has more players
|
// allow join more ppl if the other side has more players
|
||||||
else if (otherTeam > GetInvitedCount(Team))
|
else if (otherTeamInvitedCount > thisTeamInvitedCount)
|
||||||
diff = otherTeam - GetInvitedCount(Team);
|
diff = otherTeamInvitedCount - thisTeamInvitedCount;
|
||||||
|
|
||||||
// difference based on max players per team (don't allow inviting more)
|
// 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
|
// difference based on players who already entered
|
||||||
// default: allow 0
|
// default: allow 0
|
||||||
uint32 diff3 = 0;
|
uint32 diff3 = 0;
|
||||||
// allow join one person if the sides are equal (to fill up bg minplayersperteam)
|
// allow join one person if the sides are equal (to fill up bg minPlayerPerTeam)
|
||||||
if (otherIn == GetPlayersCountByTeam(Team))
|
if (otherTeamPlayersCount == thisTeamPlayersCount)
|
||||||
diff3 = 1;
|
diff3 = 1;
|
||||||
// allow join more ppl if the other side has more players
|
// allow join more ppl if the other side has more players
|
||||||
else if (otherIn > GetPlayersCountByTeam(Team))
|
else if (otherTeamPlayersCount > thisTeamPlayersCount)
|
||||||
diff3 = otherIn - GetPlayersCountByTeam(Team);
|
diff3 = otherTeamPlayersCount - thisTeamPlayersCount;
|
||||||
// or other side has less than minPlayersPerTeam
|
// or other side has less than minPlayersPerTeam
|
||||||
else if (GetInvitedCount(Team) <= GetMinPlayersPerTeam())
|
else if (thisTeamInvitedCount <= GetMinPlayersPerTeam())
|
||||||
diff3 = GetMinPlayersPerTeam() - GetInvitedCount(Team) + 1;
|
diff3 = GetMinPlayersPerTeam() - thisTeamInvitedCount + 1;
|
||||||
|
|
||||||
// return the minimum of the 3 differences
|
// return the minimum of the 3 differences
|
||||||
|
|
||||||
|
|||||||
@@ -497,24 +497,45 @@ void BattlegroundQueue::FillPlayersToBG(Battleground* bg, BattlegroundBracketId
|
|||||||
{
|
{
|
||||||
int32 hordeFree = bg->GetFreeSlotsForTeam(HORDE);
|
int32 hordeFree = bg->GetFreeSlotsForTeam(HORDE);
|
||||||
int32 aliFree = bg->GetFreeSlotsForTeam(ALLIANCE);
|
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
|
//iterator for iterating through bg queue
|
||||||
GroupsQueueType::const_iterator Ali_itr = m_QueuedGroups[bracket_id][BG_QUEUE_NORMAL_ALLIANCE].begin();
|
GroupsQueueType::const_iterator Ali_itr = m_QueuedGroups[bracket_id][BG_QUEUE_NORMAL_ALLIANCE].begin();
|
||||||
//count of groups in queue - used to stop cycles
|
//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
|
//index to queue which group is current
|
||||||
uint32 aliIndex = 0;
|
uint32 aliIndex = 0;
|
||||||
for (; aliIndex < aliCount && m_SelectionPools[TEAM_ALLIANCE].AddGroup((*Ali_itr), aliFree); aliIndex++)
|
for (; aliIndex < aliCount && m_SelectionPools[TEAM_ALLIANCE].AddGroup((*Ali_itr), aliFree); aliIndex++)
|
||||||
++Ali_itr;
|
++Ali_itr;
|
||||||
//the same thing for horde
|
//the same thing for horde
|
||||||
GroupsQueueType::const_iterator Horde_itr = m_QueuedGroups[bracket_id][BG_QUEUE_NORMAL_HORDE].begin();
|
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;
|
uint32 hordeIndex = 0;
|
||||||
for (; hordeIndex < hordeCount && m_SelectionPools[TEAM_HORDE].AddGroup((*Horde_itr), hordeFree); hordeIndex++)
|
for (; hordeIndex < hordeCount && m_SelectionPools[TEAM_HORDE].AddGroup((*Horde_itr), hordeFree); hordeIndex++)
|
||||||
++Horde_itr;
|
++Horde_itr;
|
||||||
|
|
||||||
//if ofc like BG queue invitation is set in config, then we are happy
|
//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;
|
return;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -649,7 +670,7 @@ bool BattlegroundQueue::CheckNormalMatch(Battleground* bg_template, Battleground
|
|||||||
uint32 j = TEAM_ALLIANCE;
|
uint32 j = TEAM_ALLIANCE;
|
||||||
if (m_SelectionPools[TEAM_HORDE].GetPlayerCount() < m_SelectionPools[TEAM_ALLIANCE].GetPlayerCount())
|
if (m_SelectionPools[TEAM_HORDE].GetPlayerCount() < m_SelectionPools[TEAM_ALLIANCE].GetPlayerCount())
|
||||||
j = TEAM_HORDE;
|
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)
|
&& 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
|
//we will try to invite more groups to team with less players indexed by j
|
||||||
|
|||||||
@@ -64,6 +64,13 @@ enum BattlegroundQueueGroupTypes
|
|||||||
};
|
};
|
||||||
#define BG_QUEUE_GROUP_TYPES_COUNT 4
|
#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 Battleground;
|
||||||
class BattlegroundQueue
|
class BattlegroundQueue
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -2197,6 +2197,7 @@ Battleground.StoreStatistics.Enable = 0
|
|||||||
# Don't bother with balance)
|
# Don't bother with balance)
|
||||||
# 1 - (Experimental, Don't allow to invite much more players
|
# 1 - (Experimental, Don't allow to invite much more players
|
||||||
# of one faction)
|
# of one faction)
|
||||||
|
# 2 - (Experimental, Try to have even teams)
|
||||||
|
|
||||||
Battleground.InvitationType = 0
|
Battleground.InvitationType = 0
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user