Core/BG: Move bg balance from AC

This commit is contained in:
Winfidonarleyan
2019-08-27 23:51:36 +07:00
parent 3535f05c93
commit 57938ccb61
4 changed files with 81 additions and 103 deletions

View File

@@ -1311,7 +1311,6 @@ void Battleground::AddOrSetPlayerToCorrectBgGroup(Player* player, TeamId teamId)
uint32 Battleground::GetFreeSlotsForTeam(TeamId teamId) const
{
//[AZTH]
// 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(teamId) < GetMaxPlayersPerTeam()) ? GetMaxPlayersPerTeam() - GetInvitedCount(teamId) : 0;
@@ -1374,7 +1373,6 @@ uint32 Battleground::GetFreeSlotsForTeam(TeamId teamId) const
}
return 0;
//[/AZTH]
}
uint32 Battleground::GetMaxFreeSlots() const

View File

@@ -399,63 +399,53 @@ void BattlegroundQueue::FillPlayersToBG(Battleground* bg, const int32 aliFree, c
int32 aliDiff = aliFree - int32(m_SelectionPools[TEAM_ALLIANCE].GetPlayerCount());
int32 hordeDiff = hordeFree - int32(m_SelectionPools[TEAM_HORDE].GetPlayerCount());
// [AZTH] Mik1893: Battleground Balance system 2.0
int32 invType = sWorld->getIntConfig(CONFIG_BATTLEGROUND_INVITATION_TYPE);
int32 invDiff = 0;
if (m_bgTypeId != BATTLEGROUND_RB) // if not RANDOM BATTLEGROUND, use the balance system
// check balance configuration and set the max difference between teams
switch (invType)
{
// check balance configuration and set the max difference between teams
switch (invType)
case BG_QUEUE_INVITATION_TYPE_NO_BALANCE:
return;
case BG_QUEUE_INVITATION_TYPE_BALANCED:
invDiff = 1;
break;
case BG_QUEUE_INVITATION_TYPE_EVEN:
break;
default:
return;
}
// balance the teams based on the difference allowed
while (abs(aliDiff - hordeDiff) > invDiff && (m_SelectionPools[TEAM_HORDE].GetPlayerCount() > 0 || m_SelectionPools[TEAM_ALLIANCE].GetPlayerCount() > 0))
{
// if results in more alliance players than horde:
if (aliDiff < hordeDiff)
{
case BG_QUEUE_INVITATION_TYPE_NO_BALANCE:
return;
case BG_QUEUE_INVITATION_TYPE_BALANCED:
invDiff = 1;
case BG_QUEUE_INVITATION_TYPE_EVEN:
invDiff = 0;
default:
return;
// no more alliance in pool, invite whatever we can from horde
if (!m_SelectionPools[TEAM_ALLIANCE].GetPlayerCount())
break;
// kick alliance, returns true if kicked more than needed, so then try to fill up
if (m_SelectionPools[TEAM_ALLIANCE].KickGroup(hordeDiff - aliDiff))
for (; Ali_itr != m_QueuedGroups[bracket_id][BG_QUEUE_NORMAL_ALLIANCE].end() && m_SelectionPools[TEAM_ALLIANCE].AddGroup((*Ali_itr), aliFree >= hordeDiff ? aliFree - hordeDiff : 0); ++Ali_itr);
}
// if results in more horde players than alliance:
else
{
// no more horde in pool, invite whatever we can from alliance
if (!m_SelectionPools[TEAM_HORDE].GetPlayerCount())
break;
// kick horde, returns true if kicked more than needed, so then try to fill up
if (m_SelectionPools[TEAM_HORDE].KickGroup(aliDiff - hordeDiff))
for (; Horde_itr != m_QueuedGroups[bracket_id][BG_QUEUE_NORMAL_HORDE].end() && m_SelectionPools[TEAM_HORDE].AddGroup((*Horde_itr), hordeFree >= aliDiff ? hordeFree - aliDiff : 0); ++Horde_itr);
}
// balance the teams based on the difference allowed
while (abs(aliDiff - hordeDiff) > invDiff && (m_SelectionPools[TEAM_HORDE].GetPlayerCount() > 0 || m_SelectionPools[TEAM_ALLIANCE].GetPlayerCount() > 0))
{
// if results in more alliance players than horde:
if (aliDiff < hordeDiff)
{
// no more alliance in pool, invite whatever we can from horde
if (!m_SelectionPools[TEAM_ALLIANCE].GetPlayerCount())
break;
// kick alliance, returns true if kicked more than needed, so then try to fill up
if (m_SelectionPools[TEAM_ALLIANCE].KickGroup(hordeDiff - aliDiff))
for (; Ali_itr != m_QueuedGroups[bracket_id][BG_QUEUE_NORMAL_ALLIANCE].end() && m_SelectionPools[TEAM_ALLIANCE].AddGroup((*Ali_itr), aliFree >= hordeDiff ? aliFree - hordeDiff : 0); ++Ali_itr);
}
// if results in more horde players than alliance:
else
{
// no more horde in pool, invite whatever we can from alliance
if (!m_SelectionPools[TEAM_HORDE].GetPlayerCount())
break;
// kick horde, returns true if kicked more than needed, so then try to fill up
if (m_SelectionPools[TEAM_HORDE].KickGroup(aliDiff - hordeDiff))
for (; Horde_itr != m_QueuedGroups[bracket_id][BG_QUEUE_NORMAL_HORDE].end() && m_SelectionPools[TEAM_HORDE].AddGroup((*Horde_itr), hordeFree >= aliDiff ? hordeFree - aliDiff : 0); ++Horde_itr);
}
// recalculate free space after adding
aliDiff = aliFree - int32(m_SelectionPools[TEAM_ALLIANCE].GetPlayerCount());
hordeDiff = hordeFree - int32(m_SelectionPools[TEAM_HORDE].GetPlayerCount());
}
// recalculate free space after adding
aliDiff = aliFree - static_cast<int32>(m_SelectionPools[TEAM_ALLIANCE].GetPlayerCount());
hordeDiff = hordeFree - static_cast<int32>(m_SelectionPools[TEAM_HORDE].GetPlayerCount());
}
else // unified queues, basically
{
sLog->outDebug(LOG_FILTER_BATTLEGROUND,"check min count for players - unified queue... - FILL PLAYERS TO BG ");
for (; Ali_itr != m_QueuedGroups[bracket_id][BG_QUEUE_NORMAL_ALLIANCE].end() && m_SelectionPools[TEAM_ALLIANCE].AddGroup((*Ali_itr), 100); ++Ali_itr);
for (; Horde_itr != m_QueuedGroups[bracket_id][BG_QUEUE_NORMAL_HORDE].end() && m_SelectionPools[TEAM_HORDE].AddGroup((*Horde_itr), 100); ++Horde_itr);
}
// [/AZTH]
}
void BattlegroundQueue::FillPlayersToBGWithSpecific(Battleground* bg, const int32 aliFree, const int32 hordeFree, BattlegroundBracketId thisBracketId, BattlegroundQueue* specificQueue, BattlegroundBracketId specificBracketId)
@@ -488,65 +478,55 @@ void BattlegroundQueue::FillPlayersToBGWithSpecific(Battleground* bg, const int3
GroupsQueueType::const_iterator Horde_itr = m_QueuedBoth[TEAM_HORDE].begin();
for (; Horde_itr != m_QueuedBoth[TEAM_HORDE].end() && m_SelectionPools[TEAM_HORDE].AddGroup((*Horde_itr), hordeFree); ++Horde_itr);
// calculate free space after adding
// calculate free space after adding
int32 aliDiff = aliFree - int32(m_SelectionPools[TEAM_ALLIANCE].GetPlayerCount());
int32 hordeDiff = hordeFree - int32(m_SelectionPools[TEAM_HORDE].GetPlayerCount());
// [AZTH] Mik1893: Battleground Balance system 2.0
int32 invType = sWorld->getIntConfig(CONFIG_BATTLEGROUND_INVITATION_TYPE);
int32 invDiff = 0;
if (m_bgTypeId != BATTLEGROUND_RB) // if not RANDOM BATTLEGROUND, use the balance system
// check balance configuration and set the max difference between teams
switch (invType)
{
// check balance configuration and set the max difference between teams
switch (invType)
{
case BG_QUEUE_INVITATION_TYPE_NO_BALANCE:
return;
case BG_QUEUE_INVITATION_TYPE_BALANCED:
invDiff = 1;
case BG_QUEUE_INVITATION_TYPE_EVEN:
invDiff = 0;
default:
return;
}
// if free space differs too much, ballance
while (abs(aliDiff - hordeDiff) > invDiff && (m_SelectionPools[TEAM_HORDE].GetPlayerCount() > 0 || m_SelectionPools[TEAM_ALLIANCE].GetPlayerCount() > 0))
{
// if results in more alliance players than horde:
if (aliDiff < hordeDiff)
{
// no more alliance in pool, invite whatever we can from horde
if (!m_SelectionPools[TEAM_ALLIANCE].GetPlayerCount())
break;
// kick alliance, returns true if kicked more than needed, so then try to fill up
if (m_SelectionPools[TEAM_ALLIANCE].KickGroup(hordeDiff - aliDiff))
for (; Ali_itr != m_QueuedBoth[TEAM_ALLIANCE].end() && m_SelectionPools[TEAM_ALLIANCE].AddGroup((*Ali_itr), aliFree >= hordeDiff ? aliFree - hordeDiff : 0); ++Ali_itr);
}
// if results in more horde players than alliance:
else
{
// no more horde in pool, invite whatever we can from alliance
if (!m_SelectionPools[TEAM_HORDE].GetPlayerCount())
break;
// kick horde, returns true if kicked more than needed, so then try to fill up
if (m_SelectionPools[TEAM_HORDE].KickGroup(aliDiff - hordeDiff))
for (; Horde_itr != m_QueuedBoth[TEAM_HORDE].end() && m_SelectionPools[TEAM_HORDE].AddGroup((*Horde_itr), hordeFree >= aliDiff ? hordeFree - aliDiff : 0); ++Horde_itr);
}
// recalculate free space after adding
aliDiff = aliFree - int32(m_SelectionPools[TEAM_ALLIANCE].GetPlayerCount());
hordeDiff = hordeFree - int32(m_SelectionPools[TEAM_HORDE].GetPlayerCount());
}
case BG_QUEUE_INVITATION_TYPE_NO_BALANCE:
return;
case BG_QUEUE_INVITATION_TYPE_BALANCED:
invDiff = 1;
break;
case BG_QUEUE_INVITATION_TYPE_EVEN:
break;
default:
return;
}
else // unified queues, basically - let everyone in and we handle it later
// if free space differs too much, ballance
while (abs(aliDiff - hordeDiff) > invDiff && (m_SelectionPools[TEAM_HORDE].GetPlayerCount() > 0 || m_SelectionPools[TEAM_ALLIANCE].GetPlayerCount() > 0))
{
sLog->outDebug(LOG_FILTER_BATTLEGROUND, "check min count for players - unified queue... - FILL PLAYERS TO BG WITH SPECIFIC ");
for (; Ali_itr != m_QueuedBoth[TEAM_ALLIANCE].end() && m_SelectionPools[TEAM_ALLIANCE].AddGroup((*Ali_itr), 100); ++Ali_itr);
for (; Horde_itr != m_QueuedBoth[TEAM_HORDE].end() && m_SelectionPools[TEAM_HORDE].AddGroup((*Horde_itr), 100);++Horde_itr);
// if results in more alliance players than horde:
if (aliDiff < hordeDiff)
{
// no more alliance in pool, invite whatever we can from horde
if (!m_SelectionPools[TEAM_ALLIANCE].GetPlayerCount())
break;
// kick alliance, returns true if kicked more than needed, so then try to fill up
if (m_SelectionPools[TEAM_ALLIANCE].KickGroup(hordeDiff - aliDiff))
for (; Ali_itr != m_QueuedBoth[TEAM_ALLIANCE].end() && m_SelectionPools[TEAM_ALLIANCE].AddGroup((*Ali_itr), aliFree >= hordeDiff ? aliFree - hordeDiff : 0); ++Ali_itr);
}
else // if results in more horde players than alliance:
{
// no more horde in pool, invite whatever we can from alliance
if (!m_SelectionPools[TEAM_HORDE].GetPlayerCount())
break;
// kick horde, returns true if kicked more than needed, so then try to fill up
if (m_SelectionPools[TEAM_HORDE].KickGroup(aliDiff - hordeDiff))
for (; Horde_itr != m_QueuedBoth[TEAM_HORDE].end() && m_SelectionPools[TEAM_HORDE].AddGroup((*Horde_itr), hordeFree >= aliDiff ? hordeFree - aliDiff : 0); ++Horde_itr);
}
// recalculate free space after adding
aliDiff = aliFree - static_cast<int32>(m_SelectionPools[TEAM_ALLIANCE].GetPlayerCount());
hordeDiff = hordeFree - static_cast<int32>(m_SelectionPools[TEAM_HORDE].GetPlayerCount());
}
}

View File

@@ -1107,7 +1107,7 @@ void World::LoadConfigSettings(bool reload)
m_bool_configs[CONFIG_BATTLEGROUND_TRACK_DESERTERS] = sConfigMgr->GetBoolDefault("Battleground.TrackDeserters.Enable", false);
m_int_configs[CONFIG_BATTLEGROUND_PREMATURE_FINISH_TIMER] = sConfigMgr->GetIntDefault ("Battleground.PrematureFinishTimer", 5 * MINUTE * IN_MILLISECONDS);
m_int_configs[CONFIG_BATTLEGROUND_PREMADE_GROUP_WAIT_FOR_MATCH] = sConfigMgr->GetIntDefault ("Battleground.PremadeGroupWaitForMatch", 30 * MINUTE * IN_MILLISECONDS);
m_int_configs[CONFIG_BATTLEGROUND_INVITATION_TYPE] = sConfigMgr->GetIntDefault ("Battleground.InvitationType", 0); // [AZTH] not implemented yet in core
m_int_configs[CONFIG_BATTLEGROUND_INVITATION_TYPE] = sConfigMgr->GetIntDefault ("Battleground.InvitationType", 0);
m_bool_configs[CONFIG_BG_XP_FOR_KILL] = sConfigMgr->GetBoolDefault("Battleground.GiveXPForKills", false);
m_bool_configs[CONFIG_BATTLEGROUND_RANDOM_DEBUG_ENABLE] = sConfigMgr->GetBoolDefault("Battleground.Random.Debug.Enable", true);
m_bool_configs[CONFIG_BATTLEGROUND_BIG_IN_RANDOM_ENABLE] = sConfigMgr->GetBoolDefault("Battleground.Big.In.Random.System.Enable", true);

View File

@@ -288,7 +288,7 @@ enum WorldIntConfigs
CONFIG_DISABLE_BREATHING,
CONFIG_BATTLEGROUND_PREMATURE_FINISH_TIMER,
CONFIG_BATTLEGROUND_PREMADE_GROUP_WAIT_FOR_MATCH,
CONFIG_BATTLEGROUND_INVITATION_TYPE, // [AZTH] Not implemented yet in core
CONFIG_BATTLEGROUND_INVITATION_TYPE,
CONFIG_ARENA_MAX_RATING_DIFFERENCE,
CONFIG_ARENA_RATING_DISCARD_TIMER,
CONFIG_ARENA_AUTO_DISTRIBUTE_INTERVAL_DAYS,