41 GuidSet guids(check.begin(), check.end());
45 GuidSet::const_iterator it = guids.begin();
46 o << it->ToHexString();
47 for (++it; it != guids.end(); ++it)
48 o <<
'|' << it->ToHexString();
60 return "Compatibles (Bad States)";
64 return "Compatibles (Not enough players)";
68 return "Multiple Lfg Groups";
70 return "Incompatible dungeons";
72 return "Incompatible roles";
74 return "Too many players";
76 return "Wrong group size";
97 GuidSet guids(check.begin(), check.end());
101 GuidSet::const_iterator it = guids.begin();
103 LfgQueueDataContainer::const_iterator itQueue =
QueueDataStore.find(*it);
107 auto role = itQueue->second.roles.find(*it);
108 if (role != itQueue->second.roles.end())
112 for (++it; it != guids.end(); ++it)
114 o <<
'|' << it->ToString();
119 auto role = itQueue->second.roles.find(*it);
120 if (role != itQueue->second.roles.end())
130 LfgQueueDataContainer::iterator itQueue =
QueueDataStore.find(guid);
153 if (itr->first != guid)
155 if (std::string::npos != itr->second.bestCompatible.find(sguid))
157 itr->second.bestCompatible.clear();
246 LfgCompatibleContainer::iterator it = itNext++;
247 if (std::string::npos != it->first.find(strGuid))
288 return &(itr->second);
300 TC_LOG_DEBUG(
"lfg.queue.match.check.new",
"Checking [{}] newToQueue({}), currentQueue({})", frontguid.
ToString(),
304 firstNew.push_back(frontguid);
347 check.push_back(all.front());
379 if (check.size() > 2)
390 return child_compatibles;
392 check.push_front(frontGuid);
396 uint8 numPlayers = 0;
397 uint8 numLfgGroups = 0;
398 for (GuidList::const_iterator it = check.begin(); it != check.end() && numLfgGroups < 2 && numPlayers <=
MAX_GROUP_SIZE; ++it)
401 LfgQueueDataContainer::iterator itQueue =
QueueDataStore.find(guid);
404 TC_LOG_ERROR(
"lfg.queue.match.compatibility.check",
"Guid: [{}] is not queued but listed as queued!", guid.
ToString());
410 for (LfgRolesMap::const_iterator it2 = itQueue->second.roles.begin(); it2 != itQueue->second.roles.end(); ++it2)
411 proposalGroups[it2->first] = itQueue->first.IsParty() ? itQueue->first :
ObjectGuid::Empty;
413 numPlayers += itQueue->second.roles.size();
418 proposal.
group = guid;
427 LfgQueueDataContainer::iterator itQueue =
QueueDataStore.find(check.front());
430 data.
roles = itQueue->second.roles;
438 if (numLfgGroups > 1)
453 if (check.size() > 1)
455 for (GuidList::const_iterator it = check.begin(); it != check.end(); ++it)
458 for (LfgRolesMap::const_iterator itRoles = roles.begin(); itRoles != roles.end(); ++itRoles)
460 LfgRolesMap::const_iterator itPlayer;
461 for (itPlayer = proposalRoles.begin(); itPlayer != proposalRoles.end(); ++itPlayer)
463 if (itRoles->first == itPlayer->first)
464 TC_LOG_ERROR(
"lfg.queue.match.compatibility.check",
"Guids: ERROR! Player multiple times in queue! [{}]", itRoles->first.ToString());
465 else if (
sLFGMgr->HasIgnore(itRoles->first, itPlayer->first))
468 if (itPlayer == proposalRoles.end())
469 proposalRoles[itRoles->first] = itRoles->second;
473 if (
uint8 playersize = numPlayers - proposalRoles.size())
483 std::ostringstream o;
484 for (LfgRolesMap::const_iterator it = debugRoles.begin(); it != debugRoles.end(); ++it)
485 o <<
", " << it->first.ToHexString() <<
": " <<
GetRolesString(it->second);
492 GuidList::iterator itguid = check.begin();
494 std::ostringstream o;
495 o <<
", " << itguid->ToHexString() <<
": (" <<
ConcatenateDungeons(proposalDungeons) <<
")";
496 for (++itguid; itguid != check.end(); ++itguid)
501 std::set_intersection(proposalDungeons.begin(), proposalDungeons.end(), dungeons.begin(), dungeons.end(), std::inserter(temporal, temporal.begin()));
502 proposalDungeons = temporal;
505 if (proposalDungeons.empty())
517 proposalRoles = queue.
roles;
526 data.
roles = proposalRoles;
528 for (GuidList::const_iterator itr = check.begin(); itr != check.end(); ++itr)
539 if (!
sLFGMgr->AllQueued(check))
553 for (LfgRolesMap::const_iterator itRoles = proposalRoles.begin(); itRoles != proposalRoles.end(); ++itRoles)
559 proposal.
leader = itRoles->first;
562 else if (!leader && (!proposal.
leader ||
urand(0, 1)))
563 proposal.
leader = itRoles->first;
567 data.
role = itRoles->second;
568 data.
group = proposalGroups.find(itRoles->first)->second;
574 for (GuidList::const_iterator itQueue = proposal.
queues.begin(); itQueue != proposal.
queues.end(); ++itQueue)
581 sLFGMgr->AddProposal(proposal);
590 TC_LOG_TRACE(
"lfg.queue.timers.update",
"Updating queue timers...");
603 for (LfgRolesMap::const_iterator itPlayer = queueinfo.
roles.begin(); itPlayer != queueinfo.
roles.end(); ++itPlayer)
604 role |= itPlayer->second;
605 role &= ~PLAYER_ROLE_LEADER;
629 LfgQueueStatusData queueData(queueId, dungeonId, waitTime, wtAvg, wtTank, wtHealer, wtDps, queuedTime, queueinfo.
tanks, queueinfo.
healers, queueinfo.
dps);
630 for (LfgRolesMap::const_iterator itPlayer = queueinfo.
roles.begin(); itPlayer != queueinfo.
roles.end(); ++itPlayer)
640 LfgQueueDataContainer::const_iterator itr =
QueueDataStore.find(guid);
642 return itr->second.joinTime;
651 uint32 playersInGroup = 0;
653 for (
uint8 i = 0; i < 2; ++i)
656 for (GuidList::const_iterator it = queue.begin(); it != queue.end(); ++it)
662 playersInGroup +=
sLFGMgr->GetPlayerCount(guid);
668 std::ostringstream o;
669 o <<
"Queued Players: " << players <<
" (in group: " << playersInGroup <<
") Groups: " << groups <<
"\n";
675 std::ostringstream o;
681 if (!itr->second.roles.empty())
685 for (
auto const& role : itr->second.roles)
702 TC_LOG_DEBUG(
"lfg.queue.compatibles.find",
"{}", itrQueue->first.ToString());
703 std::string sguid = itrQueue->first.ToHexString();
707 std::string::npos != itr->first.find(sguid))
720 uint8 size = std::count(key.begin(), key.end(),
'|') + 1;
722 if (size <= storedSize)
725 TC_LOG_DEBUG(
"lfg.queue.compatibles.update",
"Changed ({}) to ({}) as best compatible group for {}",
732 for (LfgRolesMap::const_iterator it = roles.begin(); it != roles.end(); ++it)
734 uint8 role = it->second;
#define TC_LOG_DEBUG(filterType__, message__,...)
#define TC_LOG_ERROR(filterType__, message__,...)
#define TC_LOG_TRACE(filterType__, message__,...)
std::list< ObjectGuid > GuidList
std::set< ObjectGuid > GuidSet
uint32 urand(uint32 min, uint32 max)
static ObjectGuid const Empty
std::string ToHexString() const
std::string ToString() const
static bool CheckGroupRoles(LfgRolesMap &groles)
Checks if given roles match, modifies given roles map with new roles.
static void SendLfgQueueStatus(ObjectGuid guid, LfgQueueStatusData const &data)
Sends queue status to player.
void AddQueueData(ObjectGuid guid, time_t joinTime, LfgDungeonSet const &dungeons, LfgRolesMap const &rolesMap)
LfgCompatibility GetCompatibles(std::string const &key)
LfgQueueDataContainer QueueDataStore
Queued groups.
time_t GetJoinTime(ObjectGuid guid) const
LfgCompatibilityData * GetCompatibilityData(std::string const &key)
void UpdateBestCompatibleInQueue(LfgQueueDataContainer::iterator itrQueue, std::string const &key, LfgRolesMap const &roles)
LfgCompatibility FindNewGroups(GuidList &check, GuidList &all)
void RemoveQueueData(ObjectGuid guid)
LFGQueue & operator=(LFGQueue const &)=delete
void UpdateQueueTimers(uint8 queueId, time_t currTime)
LfgCompatibleContainer CompatibleMapStore
Compatible dungeons.
void AddToQueue(ObjectGuid guid, bool reAdd=false)
LfgWaitTimesContainer waitTimesTankStore
Average wait time to find a group queuing as tank.
void UpdateWaitTimeAvg(int32 waitTime, uint32 dungeonId)
LfgWaitTimesContainer waitTimesAvgStore
Average wait time to find a group queuing as multiple roles.
void RemoveFromQueue(ObjectGuid guid)
GuidList currentQueueStore
Ordered list. Used to find groups.
void RemoveFromNewQueue(ObjectGuid guid)
void FindBestCompatibleInQueue(LfgQueueDataContainer::iterator itrQueue)
std::string DumpCompatibleInfo(bool full=false) const
LfgCompatibility CheckCompatibility(GuidList check)
void SetCompatibles(std::string const &key, LfgCompatibility compatibles)
void AddToCurrentQueue(ObjectGuid guid)
void RemoveFromCompatibles(ObjectGuid guid)
std::string DumpQueueInfo() const
void RemoveFromCurrentQueue(ObjectGuid guid)
void AddToNewQueue(ObjectGuid guid)
void UpdateWaitTimeHealer(int32 waitTime, uint32 dungeonId)
GuidList newToQueueStore
New groups to add to queue.
void SetCompatibilityData(std::string const &key, LfgCompatibilityData const &compatibles)
LfgWaitTimesContainer waitTimesDpsStore
Average wait time to find a group queuing as dps.
void UpdateWaitTimeTank(int32 waitTime, uint32 dungeonId)
LfgWaitTimesContainer waitTimesHealerStore
Average wait time to find a group queuing as healer.
std::string GetDetailedMatchRoles(GuidList const &check) const
void UpdateWaitTimeDps(int32 waitTime, uint32 dungeonId)
void AddToFrontCurrentQueue(ObjectGuid guid)
auto SelectRandomContainerElement(C const &container) -> std::add_const_t< decltype(*std::ranges::begin(container))> &
char const * GetCompatibleString(LfgCompatibility compatibles)
std::map< ObjectGuid, uint8 > LfgRolesMap
@ LFG_COMPATIBLES_WITH_LESS_PLAYERS
@ LFG_INCOMPATIBLES_HAS_IGNORES
@ LFG_INCOMPATIBLES_MULTIPLE_LFG_GROUPS
@ LFG_INCOMPATIBLES_NO_DUNGEONS
@ LFG_COMPATIBILITY_PENDING
@ LFG_INCOMPATIBLES_TOO_MUCH_PLAYERS
@ LFG_INCOMPATIBLES_WRONG_GROUP_SIZE
@ LFG_INCOMPATIBLES_NO_ROLES
@ LFG_COMPATIBLES_BAD_STATES
std::string ConcatenateGuids(GuidList const &check)
std::string GetRolesString(uint8 roles)
std::set< uint32 > LfgDungeonSet
std::map< ObjectGuid, ObjectGuid > LfgGroupsMap
std::string ConcatenateDungeons(LfgDungeonSet const &dungeons)
@ LFG_PROPOSAL_INITIATING
LfgCompatibility compatibility
Stores player data related to proposal to join.
ObjectGuid group
Accept status (-1 not answer | 0 Not agree | 1 agree)
LfgAnswer accept
Proposed role.
Stores group data related to proposal to join.
ObjectGuid leader
Proposal group (0 if new)
uint32 dungeonId
Proposal Id.
GuidList queues
Determines if it's new group or not.
LfgProposalPlayerContainer players
Show order in update window.
bool isNew
Dungeon Encounters.
LfgProposalState state
Dungeon to join.
ObjectGuid group
State of the proposal.
time_t cancelTime
Leader guid.
Stores player or group queue info.
LfgRolesMap roles
Selected Player Role/s.
time_t joinTime
Player queue join time (to calculate wait times)
std::string bestCompatible
Best compatible combination of people queued.
LfgDungeonSet dungeons
Selected Player/Group Dungeon/s.
uint8 healers
Healers needed.
uint32 number
Number of people used to get that wait time.