fix(bg): Fix BG queue count using wrong data source (selection pool vs queued groups)

ROOT CAUSE: QueueStatePoller was using BattlegroundQueue::GetPlayersInQueue()
which returns from m_SelectionPools (populated during matchmaking), not from
m_QueuedGroups (the actual queue). This caused the system to always see 0
players in queue even after bots were successfully queued.

SYMPTOMS:
- Bots logged "Successfully queued for BG" but next poll showed 0/10 in queue
- BG queue population kept trying to fill already-filled queues
- BGs took forever to start due to count mismatch

FIX:
- Added GetQueuedPlayersCount(teamId, bracketId) to BattlegroundQueue
- This function iterates m_QueuedGroups for the specific bracket and team
- Only counts players not already invited to a BG instance
- Updated QueueStatePoller to use the new function instead of GetPlayersInQueue()

TESTING: Verified bots are queued and count now reflects actual queued players

Co-Authored-By: Claude Opus 4.5 <[email protected]>
Signed-off-by: luis <[email protected]>
This commit is contained in:
agatho
2026-02-04 20:15:46 -03:00
committed by luis
co-authored by Claude Opus 4.5
parent cd96407829
commit 8ea5a7ffd2
3 changed files with 36 additions and 3 deletions
@@ -438,9 +438,11 @@ void QueueStatePoller::DoPollBGQueue(BattlegroundTypeId bgTypeId, BattlegroundBr
BattlegroundQueue& queue = sBattlegroundMgr->GetBattlegroundQueue(queueTypeId);
// Read queue counts (READ-ONLY API)
uint32 allianceCount = queue.GetPlayersInQueue(TEAM_ALLIANCE);
uint32 hordeCount = queue.GetPlayersInQueue(TEAM_HORDE);
// Read queue counts using the correct function that counts from m_QueuedGroups
// CRITICAL FIX: GetPlayersInQueue() returns from selection pool (matchmaking only)
// GetQueuedPlayersCount() returns actual queued players for the specific bracket
uint32 allianceCount = queue.GetQueuedPlayersCount(TEAM_ALLIANCE, bracket);
uint32 hordeCount = queue.GetQueuedPlayersCount(TEAM_HORDE, bracket);
// Get requirements from template (READ-ONLY)
BattlegroundTemplate const* bgTemplate = sBattlegroundMgr->GetBattlegroundTemplateByTypeId(bgTypeId);
@@ -422,6 +422,34 @@ uint32 BattlegroundQueue::GetPlayersInQueue(TeamId id)
return m_SelectionPools[id].GetPlayerCount();
}
uint32 BattlegroundQueue::GetQueuedPlayersCount(TeamId teamId, BattlegroundBracketId bracketId) const
{
// Count players from the actual queue, not the selection pool
// Selection pool is only populated during matchmaking
uint32 count = 0;
// Determine which queue type to check based on team
uint32 queueType = (teamId == TEAM_ALLIANCE) ? BG_QUEUE_NORMAL_ALLIANCE : BG_QUEUE_NORMAL_HORDE;
// Count players in normal queue for this bracket
for (GroupQueueInfo const* ginfo : m_QueuedGroups[bracketId][queueType])
{
// Only count players not already invited to a BG
if (!ginfo->IsInvitedToBGInstanceGUID)
count += static_cast<uint32>(ginfo->Players.size());
}
// Also check premade queue for this team
queueType = (teamId == TEAM_ALLIANCE) ? BG_QUEUE_PREMADE_ALLIANCE : BG_QUEUE_PREMADE_HORDE;
for (GroupQueueInfo const* ginfo : m_QueuedGroups[bracketId][queueType])
{
if (!ginfo->IsInvitedToBGInstanceGUID)
count += static_cast<uint32>(ginfo->Players.size());
}
return count;
}
bool BattlegroundQueue::InviteGroupToBG(GroupQueueInfo* ginfo, Battleground* bg, Team side)
{
// set side if needed
@@ -121,6 +121,9 @@ class TC_GAME_API BattlegroundQueue
SelectionPool m_SelectionPools[PVP_TEAMS_COUNT];
uint32 GetPlayersInQueue(TeamId id);
// Count all queued players for a specific team and bracket (not just selection pool)
uint32 GetQueuedPlayersCount(TeamId teamId, BattlegroundBracketId bracketId) const;
BattlegroundQueueTypeId GetQueueId() const { return m_queueId; }
private: