Skip to content

feat(WG): prioritize native faction, flip only the surplus at war start#164

Merged
Nyeriah merged 1 commit into
azerothcore:masterfrom
Nyeriah:feat/wg-native-faction-priority
Jun 10, 2026
Merged

feat(WG): prioritize native faction, flip only the surplus at war start#164
Nyeriah merged 1 commit into
azerothcore:masterfrom
Nyeriah:feat/wg-native-faction-priority

Conversation

@Nyeriah

@Nyeriah Nyeriah commented Jun 10, 2026

Copy link
Copy Markdown
Member

Summary

Changes Wintergrasp cross-faction team assignment to prioritize each player's native faction and morph only the surplus needed to even the teams, instead of the previous greedy per-join balance.

The greedy logic decided each player's side from the live in-war counts at accept time, before the final population was known. A minority-faction player who happened to accept the war invite early — when their side momentarily led — could be morphed unnecessarily, and with team-lock that wrong assignment stuck for the whole war.

How it works

On the first join of a war, the native split is snapshotted from Battlefield::GetInvitedPlayersMap (valid at that point: PlayersInWar is empty and nobody is faked yet, since core erases each accepter from InvitedPlayers only after the join hook). Then per join:

  • Minority faction → always stays native.
  • Majority faction → keeps its fair share (floor(total / 2)) native in accept order; everyone past that — the latest to commit — flips to the other side.

Example: 30 Alliance / 10 Horde queue → all 10 Horde stay Horde, 20 Alliance stay Alliance, the last 10 Alliance accepters are faked to Horde → 20 v 20 with the minimum number of faction changes. The old logic could also flip Horde players depending on accept timing.

It composes with the existing per-war team-lock (lock is checked first, so relogs stay stable) and resets each war via ClearWGWarAssignments().

Config

New CFBG.Battlefield.NativePriority.Enable (default 1). Set to 0 to fall back to the previous greedy balance.

Notes

  • Balance is computed from invited counts, so partial acceptance of the war invite can drift teams slightly off perfect 50/50 — still far fewer faction changes than greedy.
  • "Latest to commit" is approximated by war-invite accept order; there is no real queue-entry timestamp in core (PlayersInQueue is an unordered set, InvitedPlayers' time_t is the invite-expiry set in a single tick).
  • No core changes — entirely within the module, reusing the existing OnBattlefieldPlayerJoinWar hook and team-lock assignment map.

🤖 Generated with Claude Code

The greedy per-join balance flipped players based on the live in-war
counts at accept time, so a minority-faction player who accepted early
could be morphed unnecessarily and (with team-lock) stay that way.

Add a native-priority pass: snapshot the native split from the invited
maps on the first join of a war, keep the minority faction fully native,
and let the majority fill its fair share (floor(total/2)) native in
accept order. Players past that share -- the latest to commit -- flip to
even the sides, minimizing faction changes.

Gated by CFBG.Battlefield.NativePriority.Enable (default 1); disabling it
falls back to the previous greedy balance.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@Nyeriah Nyeriah merged commit b053728 into azerothcore:master Jun 10, 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.

1 participant