AzerothCore 3.3.5a
OpenSource WoW Emulator
Loading...
Searching...
No Matches
BattlegroundQueue::SelectionPool Class Reference

#include "BattlegroundQueue.h"

Public Member Functions

 SelectionPool ()
 
void Init ()
 
bool AddGroup (GroupQueueInfo *ginfo, uint32 desiredCount)
 
bool KickGroup (uint32 size)
 
uint32 GetPlayerCount () const
 

Public Attributes

GroupsQueueType SelectedGroups
 

Private Attributes

uint32 PlayerCount
 

Detailed Description

Constructor & Destructor Documentation

◆ SelectionPool()

BattlegroundQueue::SelectionPool::SelectionPool ( )
inline
114: PlayerCount(0) {};
uint32 PlayerCount
Definition: BattlegroundQueue.h:122

Member Function Documentation

◆ AddGroup()

bool BattlegroundQueue::SelectionPool::AddGroup ( GroupQueueInfo ginfo,
uint32  desiredCount 
)
116{
117 // add if we don't exceed desiredCount
118 if (!ginfo->IsInvitedToBGInstanceGUID && desiredCount >= PlayerCount + ginfo->Players.size())
119 {
120 SelectedGroups.push_back(ginfo);
121 PlayerCount += ginfo->Players.size();
122 return true;
123 }
124 return PlayerCount < desiredCount;
125}
uint32 IsInvitedToBGInstanceGUID
Definition: BattlegroundQueue.h:41
GuidSet Players
Definition: BattlegroundQueue.h:32
GroupsQueueType SelectedGroups
Definition: BattlegroundQueue.h:120

References GroupQueueInfo::IsInvitedToBGInstanceGUID, and GroupQueueInfo::Players.

Referenced by BattlegroundQueue::CheckNormalMatch(), BattlegroundQueue::CheckPremadeMatch(), BattlegroundQueue::CheckSkirmishForSameFaction(), and BattlegroundQueue::FillPlayersToBG().

◆ GetPlayerCount()

uint32 BattlegroundQueue::SelectionPool::GetPlayerCount ( ) const
inline
118{ return PlayerCount; }

References PlayerCount.

Referenced by BattlegroundQueue::CheckNormalMatch().

◆ Init()

void BattlegroundQueue::SelectionPool::Init ( )

◆ KickGroup()

bool BattlegroundQueue::SelectionPool::KickGroup ( uint32  size)
83{
84 if (SelectedGroups.empty())
85 return false;
86
87 // find last group with proper size or largest
88 bool foundProper = false;
89 GroupQueueInfo* groupToKick{ SelectedGroups.front() };
90
91 for (auto const& gInfo : SelectedGroups)
92 {
93 // if proper size - overwrite to kick last one
94 if (std::abs(int32(gInfo->Players.size()) - (int32)size) <= 1)
95 {
96 groupToKick = gInfo;
97 foundProper = true;
98 }
99 else if (!foundProper && gInfo->Players.size() >= groupToKick->Players.size())
100 groupToKick = gInfo;
101 }
102
103 // remove selected from pool
104 auto playersCountInGroup{ groupToKick->Players.size() };
105 PlayerCount -= playersCountInGroup;
106 std::erase(SelectedGroups, groupToKick);
107
108 if (foundProper)
109 return false;
110
111 return playersCountInGroup > size;
112}
std::int32_t int32
Definition: Define.h:104
Definition: BattlegroundQueue.h:31

References GroupQueueInfo::Players.

Referenced by BattlegroundQueue::FillPlayersToBG().

Member Data Documentation

◆ PlayerCount

uint32 BattlegroundQueue::SelectionPool::PlayerCount
private

Referenced by GetPlayerCount(), and Init().

◆ SelectedGroups

GroupsQueueType BattlegroundQueue::SelectionPool::SelectedGroups