Skip to content

fix: balance with premade groups#165

Merged
Nyeriah merged 1 commit into
masterfrom
fix-premade
Jun 15, 2026
Merged

fix: balance with premade groups#165
Nyeriah merged 1 commit into
masterfrom
fix-premade

Conversation

@FrancescoBorzi

@FrancescoBorzi FrancescoBorzi commented Jun 11, 2026

Copy link
Copy Markdown

Rework team selection so premade groups don't break balance

Team selection used to go through two separate code paths: a greedy newest-first loop when CFBG.EvenTeams.Enabled was off, and the pair-matching InviteSameCountGroups when it was on. Both had problems with premades:

  • the greedy path could happily start a 3v1 because it never looked back at what it had picked
  • the pair-matcher had a bug where rolled-back groups were erased from the selection pools
    without fixing the player count, leaving phantom players behind.

On top of that, the reinforcement path counted groups invited to other BG instances as if they were joining this one, and relied on GetFreeSlotsForTeam, which with Battleground.InvitationType = 0 imposes no relative cap at all.

So instead of patching each path separately, both match formation and the join-in-progress fill now go through a single routine (SelectBalancedGroups) that works in three steps:

  1. stage groups onto the smaller team in queue order
  2. then move/drop groups until the team sizes are within bounds (exact match with EvenTeams on, max diff of 1 otherwise)
  3. then write the result into the selection pools once at the end.

Groups always stay whole, i.e. a premade never gets split across teams.

That made InviteSameCountGroups, InviteGroupToBG, CrossFactionQueueInfo and both GetLowerTeamIdInBG overloads dead code, hence removed.

No config changes; all existing options keep their meaning. The one deliberate behaviour change: above CFBG.EvenTeams.MaxPlayersThreshold, reinforcement now still keeps teams within 1 player instead of going fully uncapped.

Engineered using Claude Fable.

@PkllonG

PkllonG commented Jun 11, 2026

Copy link
Copy Markdown

After testing, it doesn't affect normal use. I haven't noticed the author's situation, though.

@FrancescoBorzi

Copy link
Copy Markdown
Author

thanks for your feedback @PkllonG !

@Nyeriah Nyeriah merged commit 702df19 into master Jun 15, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants