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";
92 GuidSet guids(check.begin(), check.end());
96 GuidSet::const_iterator it = guids.begin();
98 LfgQueueDataContainer::const_iterator itQueue =
QueueDataStore.find(*it);
102 auto role = itQueue->second.roles.find(*it);
103 if (role != itQueue->second.roles.end())
107 for (++it; it != guids.end(); ++it)
109 o <<
'|' << it->ToString();
114 auto role = itQueue->second.roles.find(*it);
115 if (role != itQueue->second.roles.end())
125 LfgQueueDataContainer::iterator itQueue =
QueueDataStore.find(guid);
148 if (itr->first != guid)
150 if (std::string::npos != itr->second.bestCompatible.find(sguid))
152 itr->second.bestCompatible.clear();
241 LfgCompatibleContainer::iterator it = itNext++;
242 if (std::string::npos != it->first.find(strGuid))
274 return itr->second.compatibility;
283 return &(itr->second);
295 TC_LOG_DEBUG(
"lfg.queue.match.check.new",
"Checking [{}] newToQueue({}), currentQueue({})", frontguid.
ToString(),
299 firstNew.push_back(frontguid);
342 check.push_back(all.front());
374 if (check.size() > 2)
385 return child_compatibles;
387 check.push_front(frontGuid);
391 uint8 numPlayers = 0;
392 uint8 numLfgGroups = 0;
393 for (GuidList::const_iterator it = check.begin(); it != check.end() && numLfgGroups < 2 && numPlayers <=
MAX_GROUP_SIZE; ++it)
396 LfgQueueDataContainer::iterator itQueue =
QueueDataStore.find(guid);
399 TC_LOG_ERROR(
"lfg.queue.match.compatibility.check",
"Guid: [{}] is not queued but listed as queued!", guid.
ToString());
405 for (LfgRolesMap::const_iterator it2 = itQueue->second.roles.begin(); it2 != itQueue->second.roles.end(); ++it2)
406 proposalGroups[it2->first] = itQueue->first.IsParty() ? itQueue->first :
ObjectGuid::Empty;
408 numPlayers += itQueue->second.roles.size();
413 proposal.
group = guid;
422 LfgQueueDataContainer::iterator itQueue =
QueueDataStore.find(check.front());
425 data.
roles = itQueue->second.roles;
433 if (numLfgGroups > 1)
448 if (check.size() > 1)
450 for (GuidList::const_iterator it = check.begin(); it != check.end(); ++it)
453 for (LfgRolesMap::const_iterator itRoles = roles.begin(); itRoles != roles.end(); ++itRoles)
455 LfgRolesMap::const_iterator itPlayer;
456 for (itPlayer = proposalRoles.begin(); itPlayer != proposalRoles.end(); ++itPlayer)
458 if (itRoles->first == itPlayer->first)
459 TC_LOG_ERROR(
"lfg.queue.match.compatibility.check",
"Guids: ERROR! Player multiple times in queue! [{}]", itRoles->first.ToString());
460 else if (
sLFGMgr->HasIgnore(itRoles->first, itPlayer->first))
463 if (itPlayer == proposalRoles.end())
464 proposalRoles[itRoles->first] = itRoles->second;
468 if (
uint8 playersize = numPlayers - proposalRoles.size())
478 std::ostringstream o;
479 for (LfgRolesMap::const_iterator it = debugRoles.begin(); it != debugRoles.end(); ++it)
480 o <<
", " << it->first.ToHexString() <<
": " <<
GetRolesString(it->second);
487 GuidList::iterator itguid = check.begin();
489 std::ostringstream o;
490 o <<
", " << itguid->ToHexString() <<
": (" <<
ConcatenateDungeons(proposalDungeons) <<
")";
491 for (++itguid; itguid != check.end(); ++itguid)
496 std::set_intersection(proposalDungeons.begin(), proposalDungeons.end(), dungeons.begin(), dungeons.end(), std::inserter(temporal, temporal.begin()));
497 proposalDungeons = temporal;
500 if (proposalDungeons.empty())
512 proposalRoles = queue.
roles;
521 data.
roles = proposalRoles;
523 for (GuidList::const_iterator itr = check.begin(); itr != check.end(); ++itr)
534 if (!
sLFGMgr->AllQueued(check))
548 for (LfgRolesMap::const_iterator itRoles = proposalRoles.begin(); itRoles != proposalRoles.end(); ++itRoles)
554 proposal.
leader = itRoles->first;
557 else if (!leader && (!proposal.
leader ||
urand(0, 1)))
558 proposal.
leader = itRoles->first;
562 data.
role = itRoles->second;
563 data.
group = proposalGroups.find(itRoles->first)->second;
569 for (GuidList::const_iterator itQueue = proposal.
queues.begin(); itQueue != proposal.
queues.end(); ++itQueue)
576 sLFGMgr->AddProposal(proposal);
585 TC_LOG_TRACE(
"lfg.queue.timers.update",
"Updating queue timers...");
598 for (LfgRolesMap::const_iterator itPlayer = queueinfo.
roles.begin(); itPlayer != queueinfo.
roles.end(); ++itPlayer)
599 role |= itPlayer->second;
600 role &= ~PLAYER_ROLE_LEADER;
624 LfgQueueStatusData queueData(queueId, dungeonId, waitTime, wtAvg, wtTank, wtHealer, wtDps, queuedTime, queueinfo.
tanks, queueinfo.
healers, queueinfo.
dps);
625 for (LfgRolesMap::const_iterator itPlayer = queueinfo.
roles.begin(); itPlayer != queueinfo.
roles.end(); ++itPlayer)
635 LfgQueueDataContainer::const_iterator itr =
QueueDataStore.find(guid);
637 return itr->second.joinTime;
646 uint32 playersInGroup = 0;
648 for (
uint8 i = 0; i < 2; ++i)
651 for (GuidList::const_iterator it = queue.begin(); it != queue.end(); ++it)
657 playersInGroup +=
sLFGMgr->GetPlayerCount(guid);
663 std::ostringstream o;
664 o <<
"Queued Players: " << players <<
" (in group: " << playersInGroup <<
") Groups: " << groups <<
"\n";
670 std::ostringstream o;
676 if (!itr->second.roles.empty())
680 for (
auto const& role : itr->second.roles)
697 TC_LOG_DEBUG(
"lfg.queue.compatibles.find",
"{}", itrQueue->first.ToString());
698 std::string sguid = itrQueue->first.ToHexString();
702 std::string::npos != itr->first.find(sguid))
715 uint8 size = std::count(key.begin(), key.end(),
'|') + 1;
717 if (
size <= storedSize)
720 TC_LOG_DEBUG(
"lfg.queue.compatibles.update",
"Changed ({}) to ({}) as best compatible group for {}",
727 for (LfgRolesMap::const_iterator it = roles.begin(); it != roles.end(); ++it)
729 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
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)
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) -> typename std::add_const< decltype(*std::begin(container))>::type &
constexpr std::size_t size()
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.