Skip to content

Count players joining a battleground before adding them to the player map - #490

Open
ornfelt wants to merge 1 commit into
mangoszero:masterfrom
ornfelt:fix/bg-player-count
Open

ornfelt wants to merge 1 commit into
mangoszero:masterfrom
ornfelt:fix/bg-player-count

Conversation

@ornfelt

@ornfelt ornfelt commented Nov 11, 2026 •

Copy link
Copy Markdown

Summary

BattleGround::AddPlayer inserted the player into m_Players and only then asked IsPlayerInBattleGround(guid), which looks the player up in that same map. The check therefore always returned true and the team counts never increased (regression from #165).

With the default BattleGround.PrematureFinishTimer = 300000, the premature-finish check then saw fewer than the minimum players on both teams, and every battleground ended by premature finish five minutes after the start. A player leaving also decremented the uint32 count from zero.

Verification

  • built mangosd in Release and RelWithDebInfo
  • before: Warsong Gulch ended by premature finish five minutes after the gates opened
  • after: the same Warsong Gulch match ran on for 60 minutes; Arathi Basin and Alterac Valley also played past five minutes
  • tested on a 1.12.1 client, on a fork build that also carries local battleground changes

No database, configuration, or submodule changes are included.


This change is Reviewable

… map

AddPlayer() inserted the player into m_Players and then asked
IsPlayerInBattleGround(), which looks the player up in that same map,
so it always returned true and the team counts never increased.
With BattleGround.PrematureFinishTimer set, every battleground then
ended with a premature finish once the timer ran out after the start.
Copilot AI balanced review requested due to automatic review settings November 11, 2026 05:50
@codacy-production

Copy link
Copy Markdown

Up to standards ✅

🟢 Issues 0 issues

Results:
0 new issues

View in Codacy

🟢 Metrics 0 complexity · 0 duplication

Metric Results
Complexity 0
Duplication 0

View in Codacy

NEW Get contextual insights on your PRs based on Codacy's metrics, along with PR and Jira context, without leaving GitHub. Enable AI reviewer
TIP This summary will be updated as you push new changes.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟢 Approval recommended

No active review issues remain for the battleground team-counting change.

No open issues 🎉

What changed in this PR

Fixes battleground team counting by checking player membership before inserting the player into m_Players. This addresses the regression from #165 while preserving its protection against double-counting players who re-log.

Changes:

  • Moves the membership check before map insertion so new arrivals increment team counts.
  • Adds a comment explaining why re-logging players are already counted.
File Description
src/​game/​BattleGround/​BattleGround.cpp Corrects membership-check ordering in BattleGround::AddPlayer to restore team counts and prevent erroneous premature finishes.

Review effort: Balanced

@AppVeyorBot

Copy link
Copy Markdown

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

3 participants