diff --git a/src/modules/Playerbot/Lifecycle/Instance/QueueStatePoller.cpp b/src/modules/Playerbot/Lifecycle/Instance/QueueStatePoller.cpp index dda8bf774..43293d40c 100644 --- a/src/modules/Playerbot/Lifecycle/Instance/QueueStatePoller.cpp +++ b/src/modules/Playerbot/Lifecycle/Instance/QueueStatePoller.cpp @@ -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); diff --git a/src/server/game/Battlegrounds/BattlegroundQueue.cpp b/src/server/game/Battlegrounds/BattlegroundQueue.cpp index 1cf44b7a6..53a0129db 100644 --- a/src/server/game/Battlegrounds/BattlegroundQueue.cpp +++ b/src/server/game/Battlegrounds/BattlegroundQueue.cpp @@ -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(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(ginfo->Players.size()); + } + + return count; +} + bool BattlegroundQueue::InviteGroupToBG(GroupQueueInfo* ginfo, Battleground* bg, Team side) { // set side if needed diff --git a/src/server/game/Battlegrounds/BattlegroundQueue.h b/src/server/game/Battlegrounds/BattlegroundQueue.h index 65c4c9d57..e542e4edc 100644 --- a/src/server/game/Battlegrounds/BattlegroundQueue.h +++ b/src/server/game/Battlegrounds/BattlegroundQueue.h @@ -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: