You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
feat(Core/Battlegrounds): Match Random BG maps to recent demand - #28610
Follow-up to #28595. Random BG queues fill gradually and pop as soon as the Random BG MinPlayersPerTeam is reached, so almost every match starts at exactly that size. With Battleground.Random.CheckMapMinPlayers on, maps needing more players (EotS, SotA, ...) then practically never get picked, even on realms where matches regularly fill up to 9v9 or 10v10 once started.
Battleground.Random.CheckMapMinPlayers becomes a mode. No new config keys.
0: off (default, unchanged).
1: the existing check on the smaller team of the starting match. Same values as the old bool, so existing configs keep their behavior.
2: checks the larger of the starting match size and the recent demand of its level bracket. The recent demand is the smaller of the two teams' peak player counts in the most recently finished Random BG of that bracket, used only if it finished within the last 30 minutes. Matches still running are never counted, since those players won't join the new one.
A match picked this way can start below the map's own minimum. If the queue doesn't fill it, Battleground.PrematureFinishTimer ends it early as usual, and its lower peak then becomes the bracket's recent demand.
How it works:
Battleground tracks each team's peak player count as players join.
EndBattleground records the demand per bracket in BattlegroundMgr for BGs started from the Random BG queue (they keep BATTLEGROUND_RB as their type), only when mode 2 is set. Each finished match replaces the previous record of its bracket. It's kept in memory only, so after a restart mode 2 behaves like mode 1 until a Random BG of that bracket finishes.
The queue feeds the resulting team size into the existing filter. The full-match bypass, the zero-weight fallback and the low-level override handling are unchanged, so a recent full match (peak at the Random BG MaxPlayersPerTeam) lets the next one start in any map.
Values above 2 are rejected and fall back to 0. The expiry logic is in BattlegroundUtils and covered by unit tests.
AI-assisted Pull Requests
Important
Using AI tools to prepare pull requests is allowed, but it must be disclosed and it must follow our AC guidelines for AI Agentic Engineering (link below).
You are expected to fully understand the changes you submit and to be able to explain and justify them when maintainers ask.
AI tools (e.g. Claude, ChatGPT, or similar) were used entirely or partially to prepare this pull request. If checked, specify which tools and models below.
Live research (checked on live servers, e.g Classic WotLK, Retail, etc.)
Sniffs (remember to share them with the open source community!)
Video evidence, knowledge databases or other public sources (e.g forums, Wowhead, etc.)
The changes promoted by this pull request come partially or entirely from another project (cherry-pick). Cherry-picks must be committed using the proper --author tag in order to be accepted, thus crediting the original authors, unless otherwise unable to be found
Tests Performed:
This PR has been:
Tested in-game by the author.
Tested in-game by other community members/someone else other than the author/has been live on production servers.
This pull request requires further testing and may have edge cases to be tested.
How to Test the Changes:
This pull request can be tested by following the reproduction steps provided in the linked issue
This pull request requires further testing. Provide steps to test your changes. If it requires any specific setup e.g multiple players please specify it as well.
Set Battleground.Random.CheckMapMinPlayers = 2. Lower the minimums so small matches start: Random BG to 2 (UPDATE battleground_template SET MinPlayersPerTeam = 2 WHERE ID IN (2, 32);, which also sets Warsong Gulch to 2) and Strand of the Ancients to 3 (UPDATE battleground_template SET MinPlayersPerTeam = 3 WHERE ID = 9;). Restart.
Queue 2 level 80 players per faction for Random Battleground. The match starts in Warsong Gulch. Finish it with 3 players per faction having joined (a third player per faction joins through the queue while it runs).
Within 30 minutes of that match ending, queue 2 players per faction again. Strand of the Ancients can now come up as well as Warsong Gulch. When this match ends it records its own peak of 2 and the demand drops back, so to roll again, repeat steps 2 and 3 together. A 2v2 Strand of the Ancients ends early through Battleground.PrematureFinishTimer, since it's below its own minimum of 3.
Repeat step 2, then restart (or wait more than 30 minutes without finishing another Random BG) and queue 2 players per faction several times: every match starts in Warsong Gulch.
Set the option to 1 and repeat steps 2 and 3: every 2v2 match starts in Warsong Gulch, as before this PR.
Unit tests: unit_tests --gtest_filter=RandomBGMinPlayersFilterTest.*
Known Issues and TODO List:
[ ]
[ ]
How to Test AzerothCore PRs
When a PR is ready to be tested, it will be marked as [WAITING TO BE TESTED].
You can help by testing PRs and writing your feedback here on the PR's page on GitHub. Follow the instructions here:
REMEMBER: when testing a PR that changes something generic (i.e. a part of code that handles more than one specific thing), the tester should not only check that the PR does its job (e.g. fixing spell XXX) but especially check that the PR does not cause any regression (i.e. introducing new bugs).
For example: if a PR fixes spell X by changing a part of code that handles spells X, Y, and Z, we should not only test X, but we should test Y and Z as well.
Random BG queues pop as soon as the template minimum is reached, so
nearly every match starts at that size and maps with a higher
MinPlayersPerTeam are never picked by Battleground.Random.CheckMapMinPlayers,
even when matches regularly fill up.
The setting is now a mode. 1 keeps the current check on the starting
match size. 2 checks the larger of that and the smaller team's peak
player count in the most recently finished Random BG of the same
bracket, when it finished within the last 30 minutes. Running matches
are not counted.
The reason will be displayed to describe this comment to others. Learn more.
Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.
An organization owner can choose the repository organization as the billing source for reviews requested by members with a paid Copilot license. Learn about Copilot code review billing.
The change replaces the Random Battleground map minimum-player boolean setting with three modes. In demand mode, completed battlegrounds record the smaller peak team size by bracket, and map selection uses recent demand for up to 30 minutes. New tests cover demand adjustment, expiry, and the team-size cap.
Merge Risk: Low · up to 8a204
The change adds a recent-demand mode for Random Battleground map selection and is mostly safe. Operators who set the option to true will find the check silently disabled. Two battlegrounds in the same bracket finishing at the same moment could race on the demand record. Both issues are small and should be addressed or accepted before merge.
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.
Included review availability: This review used your included allowance. Your plan provides up to 8 included reviews per hour; 4 remain after this review.
The reason will be displayed to describe this comment to others. Learn more.
Minor · Stability & Availability · Quick win
Serialize demand publication across battleground instances.
With multiple map workers, two Random BG Alterac Valley instances in the same bracket can reach this assignment concurrently through boss-kill callbacks, which creates conflicting writes to the same non-atomic record. (raw.githubusercontent.com)
The manager update loop does not serialize these callbacks, so the demand record has undefined behavior rather than a reliable completed-match value. (raw.githubusercontent.com)
Publish through one owning thread, or synchronize publication and return a protected snapshot from GetRandomBGDemand.
The reason will be displayed to describe this comment to others. Learn more.
Minor · Functional Correctness · Quick win
Preserve existing enabled boolean values.
An existing Battleground.Random.CheckMapMinPlayers = true previously enabled checking, but the new integer parser rejects true, logs a conversion error, and uses 0, which disables checking. (raw.githubusercontent.com)
Accept the previous boolean spellings as aliases for modes 0 and 1, while retaining numeric mode 2.
By Claude Code, claude-opus-5-5 — self-review v0.10, 2026-11-29
Review details (rounds 2–3)
IntentBattleground.Random.CheckMapMinPlayers becomes a mode: 0 off, 1 the previous check on the starting match's smaller team, 2 also considers the smaller team peak of the most recently finished Random BG in the same bracket when it finished within 30 minutes; running matches are not counted and the existing bypass, fallback and low-level override handling stay.
Project rules.agents/docs/self-review-rules.md found and applied
How to Test step 3 — repeating 2v2 "several times" fails after the first roll: each ended match overwrites the recorded demand with 2 → fixed
Description — omitted that mode 2 can start a match below the map's minimum, which ends through the premature finish timer if unfilled and lowers the demand → fixed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Changes Proposed:
This PR proposes changes to:
Follow-up to #28595. Random BG queues fill gradually and pop as soon as the Random BG
MinPlayersPerTeamis reached, so almost every match starts at exactly that size. WithBattleground.Random.CheckMapMinPlayerson, maps needing more players (EotS, SotA, ...) then practically never get picked, even on realms where matches regularly fill up to 9v9 or 10v10 once started.Battleground.Random.CheckMapMinPlayersbecomes a mode. No new config keys.0: off (default, unchanged).1: the existing check on the smaller team of the starting match. Same values as the old bool, so existing configs keep their behavior.2: checks the larger of the starting match size and the recent demand of its level bracket. The recent demand is the smaller of the two teams' peak player counts in the most recently finished Random BG of that bracket, used only if it finished within the last 30 minutes. Matches still running are never counted, since those players won't join the new one.A match picked this way can start below the map's own minimum. If the queue doesn't fill it,
Battleground.PrematureFinishTimerends it early as usual, and its lower peak then becomes the bracket's recent demand.How it works:
Battlegroundtracks each team's peak player count as players join.EndBattlegroundrecords the demand per bracket inBattlegroundMgrfor BGs started from the Random BG queue (they keepBATTLEGROUND_RBas their type), only when mode 2 is set. Each finished match replaces the previous record of its bracket. It's kept in memory only, so after a restart mode 2 behaves like mode 1 until a Random BG of that bracket finishes.MaxPlayersPerTeam) lets the next one start in any map.Values above 2 are rejected and fall back to 0. The expiry logic is in
BattlegroundUtilsand covered by unit tests.AI-assisted Pull Requests
Important
Using AI tools to prepare pull requests is allowed, but it must be disclosed and it must follow our AC guidelines for AI Agentic Engineering (link below).
You are expected to fully understand the changes you submit and to be able to explain and justify them when maintainers ask.
Issues Addressed:
SOURCE:
The changes have been validated through:
Tests Performed:
This PR has been:
How to Test the Changes:
Battleground.Random.CheckMapMinPlayers = 2. Lower the minimums so small matches start: Random BG to 2 (UPDATE battleground_template SET MinPlayersPerTeam = 2 WHERE ID IN (2, 32);, which also sets Warsong Gulch to 2) and Strand of the Ancients to 3 (UPDATE battleground_template SET MinPlayersPerTeam = 3 WHERE ID = 9;). Restart.Battleground.PrematureFinishTimer, since it's below its own minimum of 3.1and repeat steps 2 and 3: every 2v2 match starts in Warsong Gulch, as before this PR.unit_tests --gtest_filter=RandomBGMinPlayersFilterTest.*Known Issues and TODO List:
How to Test AzerothCore PRs
When a PR is ready to be tested, it will be marked as [WAITING TO BE TESTED].
You can help by testing PRs and writing your feedback here on the PR's page on GitHub. Follow the instructions here:
http://www.azerothcore.org/wiki/How-to-test-a-PR
REMEMBER: when testing a PR that changes something generic (i.e. a part of code that handles more than one specific thing), the tester should not only check that the PR does its job (e.g. fixing spell XXX) but especially check that the PR does not cause any regression (i.e. introducing new bugs).
For example: if a PR fixes spell X by changing a part of code that handles spells X, Y, and Z, we should not only test X, but we should test Y and Z as well.