Skip to content

Conversation

@thesprockee
Copy link
Member

This pull request introduces two major improvements: it adds support for handling loadout save requests sent from the game server, and it refines the team balancing logic in the matchmaker backfill process. The changes include new message types, message handling, robust processing and updating of player loadouts, as well as improved and thoroughly tested logic for assigning parties to teams to maintain match balance.

Game server loadout save support:

  • Added a new message type GameServerSaveLoadoutRequest to represent loadout updates sent from the game server, including parsing and streaming logic in server/evr/gameserver_save_loadout.go.
  • Registered the new message type in the symbol cache and message factory, enabling the server to recognize and process these requests (core_hash_lookup.go, core_packet_types.go). [1] [2]
  • Implemented handling of GameServerSaveLoadoutRequest in the pipeline, including robust parsing, user lookup, profile updating, and error handling in server/evr_pipeline_gameserver_loadout.go and the main pipeline logic (evr_pipeline.go). [1] [2]

Matchmaker team balancing improvements:

  • Refined the logic for selecting which team to assign parties to during backfill, ensuring the smaller team is prioritized, both teams are considered when balanced, and fallback occurs if the preferred team is full (evr_lobby_backfill.go).
  • Added comprehensive tests to verify team balancing and fallback behavior in a variety of scenarios (evr_lobby_backfill_team_balance_test.go).
  • Clarified and enforced the assignment of entrants to teams in the lobby builder to preserve matchmaker decisions and prevent arbitrary re-splitting (evr_lobby_builder.go).

The matchmaker creates balanced teams using array position:
- Indices [0:teamSize] = Blue team
- Indices [teamSize:] = Orange team

The buildMatch function was using i/teamSize to re-split players,
which broke team assignments when array order changed, causing
5v0 scenarios.

Fixed by:
- Using array slicing to preserve matchmaker's team assignments
- Adding validation to ensure even entrant count
- Removing naive i/teamSize calculation
- Added clarifying comments about team assignment contract
Tests verify:
- Even split validation (rejects odd numbers)
- Matchmaker ordering preservation (first half = team 0, second half = team 1)
- Party cohesion across teams
- No team reassignment using buggy i/teamSize approach
- Correct team index assignment to EntrantPresenceFromSession
- Performance benchmarks for slicing vs loop approach

These tests ensure the fix prevents 5v0 scenarios by validating that
the lobby builder preserves the matchmaker's balanced team assignments.
The backfill logic had issues when selecting teams:
1. When teams were equal size, it only considered blue team
2. The fallback logic only triggered when NO teams were added
3. This could lead to consistently filling one team first

Fixed by:
- Use strict < comparison instead of <= to identify smaller team
- When teams are equal, consider BOTH teams for better match quality
- Fallback only triggers when smaller team is full
- Add comprehensive tests for all team balance scenarios

This prevents backfill from creating unbalanced teams (e.g., 5v1, 4v0)
and ensures the scoring function can choose the best team assignment
when teams are balanced.
Copilot AI review requested due to automatic review settings January 5, 2026 21:50
Signed-off-by: Andrew Bates <a@sprock.io>
@thesprockee thesprockee merged commit ac8b491 into main Jan 5, 2026
1 check passed
@thesprockee thesprockee deleted the fix/loadout-handling branch January 5, 2026 21:51
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR introduces comprehensive support for game server-initiated loadout save requests and improves team balancing logic in the matchmaker backfill system. The changes enable players' cosmetic customizations to be persisted when updated from the game server, and ensures more balanced team assignments during match backfilling.

  • Adds new GameServerSaveLoadoutRequest message type and complete handling pipeline for loadout persistence
  • Refines matchmaker backfill logic to prioritize smaller teams and handle equal team scenarios more intelligently
  • Includes comprehensive test coverage for team assignment and backfill balancing behavior

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated no comments.

Show a summary per file
File Description
server/evr/gameserver_save_loadout.go Defines the new GameServerSaveLoadoutRequest message structure with binary encoding/decoding support
server/evr/core_packet_types.go Registers the new loadout message type in the message factory
server/evr/core_hash_lookup.go Adds symbol cache entry for the loadout request message type
server/evr_pipeline_gameserver_loadout.go Implements handler for processing loadout save requests including user lookup, profile updates, and error handling
server/evr_pipeline.go Integrates loadout handler into the main EVR pipeline message processing flow
server/evr_lobby_builder.go Replaces loop-based team splitting with array slicing to preserve matchmaker-determined team assignments
server/evr_lobby_backfill.go Refines team selection logic to prioritize smaller teams with fallback handling
server/evr_lobby_builder_team_assignment_test.go Adds comprehensive tests for team assignment logic with benchmarks
server/evr_lobby_backfill_team_balance_test.go Adds tests verifying team balancing behavior in various scenarios

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.

2 participants