43 GuidSet guids(check.begin(), check.end());
47 GuidSet::const_iterator it = guids.begin();
48 o << it->GetRawValue();
49 for (++it; it != guids.end(); ++it)
50 o <<
'|' << it->GetRawValue();
62 return "Compatibles (Bad States)";
66 return "Compatibles (Not enough players)";
70 return "Multiple Lfg Groups";
72 return "Incompatible dungeons";
74 return "Incompatible roles";
76 return "Too many players";
78 return "Wrong group size";
94 GuidSet guids(check.begin(), check.end());
98 GuidSet::const_iterator it = guids.begin();
99 o << it->GetRawValue();
100 LfgQueueDataContainer::const_iterator itQueue =
QueueDataStore.find(*it);
104 auto role = itQueue->second.roles.find(*it);
105 if (role != itQueue->second.roles.end())
109 for (++it; it != guids.end(); ++it)
111 o <<
'|' << it->GetRawValue();
116 auto role = itQueue->second.roles.find(*it);
117 if (role != itQueue->second.roles.end())
127 LfgQueueDataContainer::iterator itQueue =
QueueDataStore.find(guid);
146 std::ostringstream o;
148 std::string sguid = o.str();
152 if (itr->first != guid)
154 if (std::string::npos != itr->second.bestCompatible.find(sguid))
156 itr->second.bestCompatible.clear();
240 std::stringstream out;
242 std::string strGuid = out.str();
247 LfgCompatibleContainer::iterator it = itNext++;
248 if (std::string::npos != it->first.find(strGuid))
289 return &(itr->second);
301 TC_LOG_DEBUG(
"lfg.queue.match.check.new",
"Checking [{}] newToQueue({}), currentQueue({})", frontguid.
ToString(),
305 firstNew.push_back(frontguid);
348 check.push_back(all.front());
380 if (check.size() > 2)
391 return child_compatibles;
393 check.push_front(frontGuid);
397 uint8 numPlayers = 0;
398 uint8 numLfgGroups = 0;
399 for (GuidList::const_iterator it = check.begin(); it != check.end() && numLfgGroups < 2 && numPlayers <=
MAX_GROUP_SIZE; ++it)
402 LfgQueueDataContainer::iterator itQueue =
QueueDataStore.find(guid);
405 TC_LOG_ERROR(
"lfg.queue.match.compatibility.check",
"Guid: [{}] is not queued but listed as queued!", guid.
ToString());
411 for (LfgRolesMap::const_iterator it2 = itQueue->second.roles.begin(); it2 != itQueue->second.roles.end(); ++it2)
412 proposalGroups[it2->first] = itQueue->first.IsGroup() ? itQueue->first :
ObjectGuid::Empty;
414 numPlayers += itQueue->second.roles.size();
419 proposal.
group = guid;
428 LfgQueueDataContainer::iterator itQueue =
QueueDataStore.find(check.front());
431 data.
roles = itQueue->second.roles;
439 if (numLfgGroups > 1)
454 if (check.size() > 1)
456 for (GuidList::const_iterator it = check.begin(); it != check.end(); ++it)
459 for (LfgRolesMap::const_iterator itRoles = roles.begin(); itRoles != roles.end(); ++itRoles)
461 LfgRolesMap::const_iterator itPlayer;
462 for (itPlayer = proposalRoles.begin(); itPlayer != proposalRoles.end(); ++itPlayer)
464 if (itRoles->first == itPlayer->first)
465 TC_LOG_ERROR(
"lfg.queue.match.compatibility.check",
"Guids: ERROR! Player multiple times in queue! [{}]", itRoles->first.ToString());
466 else if (
sLFGMgr->HasIgnore(itRoles->first, itPlayer->first))
469 if (itPlayer == proposalRoles.end())
470 proposalRoles[itRoles->first] = itRoles->second;
474 if (
uint8 playersize = numPlayers - proposalRoles.size())
484 std::ostringstream o;
485 for (LfgRolesMap::const_iterator it = debugRoles.begin(); it != debugRoles.end(); ++it)
486 o <<
", " << it->first.GetRawValue() <<
": " <<
GetRolesString(it->second);
493 GuidList::iterator itguid = check.begin();
495 std::ostringstream o;
496 o <<
", " << itguid->GetRawValue() <<
": (" <<
ConcatenateDungeons(proposalDungeons) <<
")";
497 for (++itguid; itguid != check.end(); ++itguid)
502 std::set_intersection(proposalDungeons.begin(), proposalDungeons.end(), dungeons.begin(), dungeons.end(), std::inserter(temporal, temporal.begin()));
503 proposalDungeons = temporal;
506 if (proposalDungeons.empty())
518 proposalRoles = queue.
roles;
527 data.
roles = proposalRoles;
529 for (GuidList::const_iterator itr = check.begin(); itr != check.end(); ++itr)
540 if (!
sLFGMgr->AllQueued(check))
554 for (LfgRolesMap::const_iterator itRoles = proposalRoles.begin(); itRoles != proposalRoles.end(); ++itRoles)
560 proposal.
leader = itRoles->first;
563 else if (!leader && (!proposal.
leader ||
urand(0, 1)))
564 proposal.
leader = itRoles->first;
568 data.
role = itRoles->second;
569 data.
group = proposalGroups.find(itRoles->first)->second;
575 for (GuidList::const_iterator itQueue = proposal.
queues.begin(); itQueue != proposal.
queues.end(); ++itQueue)
582 sLFGMgr->AddProposal(proposal);
591 TC_LOG_TRACE(
"lfg.queue.timers.update",
"Updating queue timers...");
604 for (LfgRolesMap::const_iterator itPlayer = queueinfo.
roles.begin(); itPlayer != queueinfo.
roles.end(); ++itPlayer)
605 role |= itPlayer->second;
606 role &= ~PLAYER_ROLE_LEADER;
631 for (LfgRolesMap::const_iterator itPlayer = queueinfo.
roles.begin(); itPlayer != queueinfo.
roles.end(); ++itPlayer)
641 LfgQueueDataContainer::const_iterator itr =
QueueDataStore.find(guid);
643 return itr->second.joinTime;
652 uint32 playersInGroup = 0;
654 for (
uint8 i = 0; i < 2; ++i)
657 for (GuidList::const_iterator it = queue.begin(); it != queue.end(); ++it)
663 playersInGroup +=
sLFGMgr->GetPlayerCount(guid);
669 std::ostringstream o;
670 o <<
"Queued Players: " << players <<
" (in group: " << playersInGroup <<
") Groups: " << groups <<
"\n";
676 std::ostringstream o;
682 if (!itr->second.roles.empty())
686 for (
auto const& role : itr->second.roles)
703 TC_LOG_DEBUG(
"lfg.queue.compatibles.find",
"{}", itrQueue->first.ToString());
704 std::ostringstream o;
705 o << itrQueue->first.GetRawValue();
706 std::string sguid = o.str();
710 std::string::npos != itr->first.find(sguid))
723 uint8 size = std::count(key.begin(), key.end(),
'|') + 1;
725 if (size <= storedSize)
728 TC_LOG_DEBUG(
"lfg.queue.compatibles.update",
"Changed ({}) to ({}) as best compatible group for {}",
735 for (LfgRolesMap::const_iterator it = roles.begin(); it != roles.end(); ++it)
737 uint8 role = it->second;
#define TC_LOG_DEBUG(filterType__,...)
#define TC_LOG_TRACE(filterType__,...)
#define TC_LOG_ERROR(filterType__,...)
std::list< ObjectGuid > GuidList
std::set< ObjectGuid > GuidSet
uint32 urand(uint32 min, uint32 max)
static ObjectGuid const Empty
uint64 GetRawValue() 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
void UpdateQueueTimers(time_t currTime)
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)
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) -> typename std::add_const< decltype(*std::begin(container))>::type &
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.