AzerothCore 3.3.5a
OpenSource WoW Emulator
Loading...
Searching...
No Matches
lfg::Lfg5Guids Class Reference

#include "LFG.h"

Public Member Functions

 Lfg5Guids ()
 
 Lfg5Guids (ObjectGuid g)
 
 Lfg5Guids (Lfg5Guids const &x)
 
 Lfg5Guids (Lfg5Guids const &x, bool)
 
 ~Lfg5Guids ()
 
void addRoles (LfgRolesMap const &r)
 
void clear ()
 
bool empty () const
 
ObjectGuid front () const
 
uint8 size () const
 
void insert (const ObjectGuid &g)
 
void force_insert_front (const ObjectGuid &g)
 
void remove (const ObjectGuid &g)
 
bool hasGuid (const ObjectGuid &g) const
 
bool operator< (const Lfg5Guids &x) const
 
bool operator== (const Lfg5Guids &x) const
 
void operator= (const Lfg5Guids &x)
 
std::string toString () const
 

Public Attributes

std::array< ObjectGuid, 5 > guids = { }
 
LfgRolesMaproles
 

Detailed Description

Constructor & Destructor Documentation

◆ Lfg5Guids() [1/4]

lfg::Lfg5Guids::Lfg5Guids ( )
inline
123 {
125 roles = nullptr;
126 }
LfgRolesMap * roles
Definition: LFG.h:121
std::array< ObjectGuid, 5 > guids
Definition: LFG.h:120
static ObjectGuid const Empty
Definition: ObjectGuid.h:122

References ObjectGuid::Empty, guids, and roles.

◆ Lfg5Guids() [2/4]

lfg::Lfg5Guids::Lfg5Guids ( ObjectGuid  g)
inline
129 {
131 guids[0] = g;
132 roles = nullptr;
133 }

References ObjectGuid::Empty, guids, and roles.

◆ Lfg5Guids() [3/4]

lfg::Lfg5Guids::Lfg5Guids ( Lfg5Guids const &  x)
inline
136 {
137 guids = x.guids;
138 roles = x.roles ? (new LfgRolesMap(*(x.roles))) : nullptr;
139 }
std::map< ObjectGuid, uint8 > LfgRolesMap
Definition: LFG.h:114

References guids, and roles.

◆ Lfg5Guids() [4/4]

lfg::Lfg5Guids::Lfg5Guids ( Lfg5Guids const &  x,
bool   
)
inline
142 {
143 guids = x.guids;
144 roles = nullptr;
145 }

References guids, and roles.

◆ ~Lfg5Guids()

lfg::Lfg5Guids::~Lfg5Guids ( )
inline
147{ delete roles; }

References roles.

Member Function Documentation

◆ addRoles()

void lfg::Lfg5Guids::addRoles ( LfgRolesMap const &  r)
inline
148{ roles = new LfgRolesMap(r); }

References roles.

Referenced by lfg::LFGQueue::CheckCompatibility().

◆ clear()

void lfg::Lfg5Guids::clear ( )
inline
149{ guids.fill(ObjectGuid::Empty); }

References ObjectGuid::Empty, and guids.

◆ empty()

bool lfg::Lfg5Guids::empty ( ) const
inline

◆ force_insert_front()

void lfg::Lfg5Guids::force_insert_front ( const ObjectGuid g)
inline
272 {
273 if (guids[3])
274 {
275 guids[4] = guids[3];
276 }
277
278 if (guids[2])
279 {
280 guids[3] = guids[2];
281 }
282
283 if (guids[1])
284 {
285 guids[2] = guids[1];
286 }
287
288 guids[1] = guids[0];
289 guids[0] = g;
290 }

References guids.

Referenced by lfg::LFGQueue::CheckCompatibility().

◆ front()

ObjectGuid lfg::Lfg5Guids::front ( ) const
inline
151{ return guids[0]; }

References guids.

Referenced by lfg::LFGQueue::CheckCompatibility().

◆ hasGuid()

bool lfg::Lfg5Guids::hasGuid ( const ObjectGuid g) const
inline
426 {
427 return g && (guids[0] == g || guids[1] == g || guids[2] == g || guids[3] == g || guids[4] == g);
428 }

References guids.

◆ insert()

void lfg::Lfg5Guids::insert ( const ObjectGuid g)
inline
181 {
182 // avoid loops for performance
183 if (!guids[0])
184 {
185 guids[0] = g;
186 return;
187 }
188
189 if (g <= guids[0])
190 {
191 if (guids[3])
192 {
193 guids[4] = guids[3];
194 }
195
196 if (guids[2])
197 {
198 guids[3] = guids[2];
199 }
200
201 if (guids[1])
202 {
203 guids[2] = guids[1];
204 }
205
206 guids[1] = guids[0];
207 guids[0] = g;
208
209 return;
210 }
211
212 if (!guids[1])
213 {
214 guids[1] = g;
215 return;
216 }
217
218 if (g <= guids[1])
219 {
220 if (guids[3])
221 {
222 guids[4] = guids[3];
223 }
224
225 if (guids[2])
226 {
227 guids[3] = guids[2];
228 }
229
230 guids[2] = guids[1];
231 guids[1] = g;
232
233 return;
234 }
235
236 if (!guids[2])
237 {
238 guids[2] = g;
239 return;
240 }
241
242 if (g <= guids[2])
243 {
244 if (guids[3])
245 {
246 guids[4] = guids[3];
247 }
248
249 guids[3] = guids[2];
250 guids[2] = g;
251
252 return;
253 }
254
255 if (!guids[3])
256 {
257 guids[3] = g;
258 return;
259 }
260
261 if (g <= guids[3])
262 {
263 guids[4] = guids[3];
264 guids[3] = g;
265 return;
266 }
267
268 guids[4] = g;
269 }

References guids.

Referenced by lfg::LFGQueue::CheckCompatibility().

◆ operator<()

bool lfg::Lfg5Guids::operator< ( const Lfg5Guids x) const
inline
431 {
432 if (guids[0] <= x.guids[0])
433 {
434 if (guids[0] != x.guids[0])
435 {
436 return true;
437 }
438
439 if (guids[1] <= x.guids[1])
440 {
441 if (guids[1] != x.guids[1])
442 {
443 return true;
444 }
445
446 if (guids[2] <= x.guids[2])
447 {
448 if (guids[2] != x.guids[2])
449 {
450 return true;
451 }
452
453 if (guids[3] <= x.guids[3])
454 {
455 if (guids[3] != x.guids[3])
456 {
457 return true;
458 }
459
460 if (guids[4] <= x.guids[4])
461 {
462 return !(guids[4] == x.guids[4]);
463 }
464 }
465 }
466 }
467 }
468
469 return false;
470 }

References guids.

◆ operator=()

void lfg::Lfg5Guids::operator= ( const Lfg5Guids x)
inline
478 {
479 guids = x.guids;
480 delete roles;
481 roles = x.roles ? (new LfgRolesMap(*(x.roles))) : nullptr;
482 }

References guids, and roles.

◆ operator==()

bool lfg::Lfg5Guids::operator== ( const Lfg5Guids x) const
inline
473 {
474 return guids[0] == x.guids[0] && guids[1] == x.guids[1] && guids[2] == x.guids[2] && guids[3] == x.guids[3] && guids[4] == x.guids[4];
475 }

References guids.

◆ remove()

void lfg::Lfg5Guids::remove ( const ObjectGuid g)
inline
293 {
294 // avoid loops for performance
295 if (guids[0] == g)
296 {
297 if (guids[1])
298 {
299 guids[0] = guids[1];
300 }
301 else
302 {
303 guids[0].Clear();
304 return;
305 }
306
307 if (guids[2])
308 {
309 guids[1] = guids[2];
310 }
311 else
312 {
313 guids[1].Clear();
314 return;
315 }
316
317 if (guids[3])
318 {
319 guids[2] = guids[3];
320 }
321 else
322 {
323 guids[2].Clear();
324 return;
325 }
326
327 if (guids[4])
328 {
329 guids[3] = guids[4];
330 }
331 else
332 {
333 guids[3].Clear();
334 return;
335 }
336
337 guids[4].Clear();
338 return;
339 }
340
341 if (guids[1] == g)
342 {
343 if (guids[2])
344 {
345 guids[1] = guids[2];
346 }
347 else
348 {
349 guids[1].Clear();
350 return;
351 }
352
353 if (guids[3])
354 {
355 guids[2] = guids[3];
356 }
357 else
358 {
359 guids[2].Clear();
360 return;
361 }
362
363 if (guids[4])
364 {
365 guids[3] = guids[4];
366 }
367 else
368 {
369 guids[3].Clear();
370 return;
371 }
372
373 guids[4].Clear();
374 return;
375 }
376
377 if (guids[2] == g)
378 {
379 if (guids[3])
380 {
381 guids[2] = guids[3];
382 }
383 else
384 {
385 guids[2].Clear();
386 return;
387 }
388
389 if (guids[4])
390 {
391 guids[3] = guids[4];
392 }
393 else
394 {
395 guids[3].Clear();
396 return;
397 }
398
399 guids[4].Clear();
400 return;
401 }
402
403 if (guids[3] == g)
404 {
405 if (guids[4])
406 {
407 guids[3] = guids[4];
408 }
409 else
410 {
411 guids[3].Clear();
412 return;
413 }
414
415 guids[4].Clear();
416 return;
417 }
418
419 if (guids[4] == g)
420 {
421 guids[4].Clear();
422 }
423 }

References guids.

Referenced by lfg::LFGMgr::RemoveProposal().

◆ size()

uint8 lfg::Lfg5Guids::size ( ) const
inline
154 {
155 if (guids[2])
156 {
157 if (guids[4])
158 {
159 return 5;
160 }
161 else if (guids[3])
162 {
163 return 4;
164 }
165
166 return 3;
167 }
168 else if (guids[1])
169 {
170 return 2;
171 }
172 else if (guids[0])
173 {
174 return 1;
175 }
176
177 return 0;
178 }

References guids.

Referenced by lfg::LFGQueue::CheckCompatibility(), and lfg::LFGQueue::UpdateBestCompatibleInQueue().

◆ toString()

std::string lfg::Lfg5Guids::toString ( ) const
inline
485 {
486 std::ostringstream o;
487 o << guids[0].ToString().c_str() << "," << guids[1].ToString().c_str() << "," << guids[2].ToString().c_str() << "," << guids[3].ToString().c_str() << "," << guids[4].ToString().c_str() << ":" << (roles ? 1 : 0);
488 return o.str();
489 }

References guids, and roles.

Referenced by lfg::LFGQueue::AddToCompatibles(), lfg::LFGQueue::CheckCompatibility(), and lfg::LFGQueue::UpdateBestCompatibleInQueue().

Member Data Documentation

◆ guids

◆ roles