TrinityCore
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
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
 

Constructor & Destructor Documentation

BattlegroundQueue::SelectionPool::SelectionPool ( )
inline
116 : PlayerCount(0) { }
uint32 PlayerCount
Definition: BattlegroundQueue.h:124

Member Function Documentation

bool BattlegroundQueue::SelectionPool::AddGroup ( GroupQueueInfo ginfo,
uint32  desiredCount 
)
110 {
111  //if group is larger than desired count - don't allow to add it to pool
112  if (!ginfo->IsInvitedToBGInstanceGUID && desiredCount >= PlayerCount + ginfo->Players.size())
113  {
114  SelectedGroups.push_back(ginfo);
115  // increase selected players count
116  PlayerCount += ginfo->Players.size();
117  return true;
118  }
119  if (PlayerCount < desiredCount)
120  return true;
121  return false;
122 }
uint32 PlayerCount
Definition: BattlegroundQueue.h:124
GroupsQueueType SelectedGroups
Definition: BattlegroundQueue.h:122
std::map< ObjectGuid, PlayerQueueInfo * > Players
Definition: BattlegroundQueue.h:43
uint32 IsInvitedToBGInstanceGUID
Definition: BattlegroundQueue.h:51

+ Here is the caller graph for this function:

uint32 BattlegroundQueue::SelectionPool::GetPlayerCount ( ) const
inline
120 {return PlayerCount;}
uint32 PlayerCount
Definition: BattlegroundQueue.h:124

+ Here is the caller graph for this function:

void BattlegroundQueue::SelectionPool::Init ( )
67 {
68  SelectedGroups.clear();
69  PlayerCount = 0;
70 }
uint32 PlayerCount
Definition: BattlegroundQueue.h:124
GroupsQueueType SelectedGroups
Definition: BattlegroundQueue.h:122

+ Here is the caller graph for this function:

bool BattlegroundQueue::SelectionPool::KickGroup ( uint32  size)
77 {
78  //find maxgroup or LAST group with size == size and kick it
79  bool found = false;
80  GroupsQueueType::iterator groupToKick = SelectedGroups.begin();
81  for (GroupsQueueType::iterator itr = groupToKick; itr != SelectedGroups.end(); ++itr)
82  {
83  if (abs((int32)((*itr)->Players.size() - size)) <= 1)
84  {
85  groupToKick = itr;
86  found = true;
87  }
88  else if (!found && (*itr)->Players.size() >= (*groupToKick)->Players.size())
89  groupToKick = itr;
90  }
91  //if pool is empty, do nothing
92  if (GetPlayerCount())
93  {
94  //update player count
95  GroupQueueInfo* ginfo = (*groupToKick);
96  SelectedGroups.erase(groupToKick);
97  PlayerCount -= ginfo->Players.size();
98  //return false if we kicked smaller group or there are enough players in selection pool
99  if (ginfo->Players.size() <= size + 1)
100  return false;
101  }
102  return true;
103 }
G3D::Matrix abs(const G3D::Matrix &M)
Definition: Matrix.h:632
uint32 PlayerCount
Definition: BattlegroundQueue.h:124
int32_t int32
Definition: Define.h:146
Definition: BattlegroundQueue.h:41
GroupsQueueType SelectedGroups
Definition: BattlegroundQueue.h:122
uint32 GetPlayerCount() const
Definition: BattlegroundQueue.h:120
std::map< ObjectGuid, PlayerQueueInfo * > Players
Definition: BattlegroundQueue.h:43

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

Member Data Documentation

uint32 BattlegroundQueue::SelectionPool::PlayerCount
private
GroupsQueueType BattlegroundQueue::SelectionPool::SelectedGroups

The documentation for this class was generated from the following files: