From 9ceeb95556019e171f6f50d774840ab9edc3b62c Mon Sep 17 00:00:00 2001 From: FrancescoBorzi Date: Thu, 2 Jul 2026 17:26:05 +0200 Subject: [PATCH 1/2] fix: stop flipping tie candidates off their native faction --- src/CFBG.cpp | 10 ++-------- src/CFBG.h | 2 +- 2 files changed, 3 insertions(+), 9 deletions(-) diff --git a/src/CFBG.cpp b/src/CFBG.cpp index b2d9b97..edd731a 100644 --- a/src/CFBG.cpp +++ b/src/CFBG.cpp @@ -224,11 +224,11 @@ TeamId CFBG::ResolveBalancedTeam(TeamBalanceContext const& ctx) if (std::abs(avgLvlAlliance - avgLvlHorde) >= 0.5f) team = avgLvlAlliance < avgLvlHorde ? TEAM_ALLIANCE : TEAM_HORDE; - else // it's balanced, so we should only check the ilvl + else if (ctx.avgIlvlA != ctx.avgIlvlH) // levels balanced, ilvl breaks the tie; an exact ilvl tie keeps the current pick team = ctx.avgIlvlA < ctx.avgIlvlH ? TEAM_ALLIANCE : TEAM_HORDE; } } - else if (ctx.levelSumA == ctx.levelSumH) + else if (ctx.levelSumA == ctx.levelSumH && ctx.avgIlvlA != ctx.avgIlvlH) { team = ctx.avgIlvlA < ctx.avgIlvlH ? TEAM_ALLIANCE : TEAM_HORDE; } @@ -781,12 +781,6 @@ void CFBG::SelectBalancedGroups(BattlegroundQueue* queue, BattlegroundBracketId ctx.levelSumA = baseLevelSum[TEAM_ALLIANCE] + stagedLevelSum[TEAM_ALLIANCE]; ctx.levelSumH = baseLevelSum[TEAM_HORDE] + stagedLevelSum[TEAM_HORDE]; - // Fold the candidate's level sum into its projected side. - if (gInfo->teamId == TEAM_ALLIANCE) - ctx.levelSumA += cfInfo.SumPlayerLevel; - else - ctx.levelSumH += cfInfo.SumPlayerLevel; - // ilvl metric: live BG average when reinforcing, staged sums at formation. ctx.avgIlvlA = bg ? GetBGTeamAverageItemLevel(bg, TEAM_ALLIANCE) : stagedIlvlSum[TEAM_ALLIANCE]; ctx.avgIlvlH = bg ? GetBGTeamAverageItemLevel(bg, TEAM_HORDE) : stagedIlvlSum[TEAM_HORDE]; diff --git a/src/CFBG.h b/src/CFBG.h index 0cfb317..9411b69 100644 --- a/src/CFBG.h +++ b/src/CFBG.h @@ -99,7 +99,7 @@ struct TeamBalanceContext { int32 countA{ 0 }; // head counts, candidate EXCLUDED int32 countH{ 0 }; - uint32 levelSumA{ 0 }; // candidate level ALREADY folded into its side + uint32 levelSumA{ 0 }; // level sums, candidate EXCLUDED (like the counts) uint32 levelSumH{ 0 }; uint32 avgIlvlA{ 0 }; // per-team ilvl metric (bg avg OR queue sum) uint32 avgIlvlH{ 0 }; From 88544d715004f29fc0ee546b8c07e342aae2e1ff Mon Sep 17 00:00:00 2001 From: FrancescoBorzi Date: Thu, 2 Jul 2026 17:26:21 +0200 Subject: [PATCH 2/2] fix: document Avg.Ilvl knob only applies when BalancedTeams is off --- conf/CFBG.conf.dist | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/conf/CFBG.conf.dist b/conf/CFBG.conf.dist index e9c91b1..91a99df 100644 --- a/conf/CFBG.conf.dist +++ b/conf/CFBG.conf.dist @@ -61,7 +61,11 @@ # Default: "" - (no class skipped) # # CFBG.Include.Avg.Ilvl.Enable -# Description: Enable check average item level for bg +# Description: Enable check average item level for bg. +# Only takes effect when CFBG.BalancedTeams = 0. When +# CFBG.BalancedTeams = 1 the average item level is always +# consulted as an intrinsic tiebreaker of the balancing +# cascade, regardless of this setting. # Default: 0 # # CFBG.BalancedTeams