mirror of
https://github.com/mod-playerbots/azerothcore-wotlk.git
synced 2026-01-23 21:56:22 +00:00
converted all tabs to 4 spaces
This commit is contained in:
@@ -32,84 +32,84 @@ namespace lfg
|
||||
|
||||
void LFGQueue::AddToQueue(uint64 guid, bool failedProposal)
|
||||
{
|
||||
//sLog->outString("ADD AddToQueue: %u, failed proposal: %u", GUID_LOPART(guid), failedProposal ? 1 : 0);
|
||||
//sLog->outString("ADD AddToQueue: %u, failed proposal: %u", GUID_LOPART(guid), failedProposal ? 1 : 0);
|
||||
LfgQueueDataContainer::iterator itQueue = QueueDataStore.find(guid);
|
||||
if (itQueue == QueueDataStore.end())
|
||||
{
|
||||
sLog->outError("LFGQueue::AddToQueue: Queue data not found for [" UI64FMTD "]", guid);
|
||||
return;
|
||||
}
|
||||
//sLog->outString("AddToQueue success: %u", GUID_LOPART(guid));
|
||||
//sLog->outString("AddToQueue success: %u", GUID_LOPART(guid));
|
||||
AddToNewQueue(guid, failedProposal);
|
||||
}
|
||||
|
||||
void LFGQueue::RemoveFromQueue(uint64 guid, bool partial)
|
||||
{
|
||||
//sLog->outString("REMOVE RemoveFromQueue: %u, partial: %u", GUID_LOPART(guid), partial ? 1 : 0);
|
||||
//sLog->outString("REMOVE RemoveFromQueue: %u, partial: %u", GUID_LOPART(guid), partial ? 1 : 0);
|
||||
RemoveFromNewQueue(guid);
|
||||
RemoveFromCompatibles(guid);
|
||||
|
||||
LfgQueueDataContainer::iterator itDelete = QueueDataStore.end();
|
||||
for (LfgQueueDataContainer::iterator itr = QueueDataStore.begin(); itr != QueueDataStore.end(); ++itr)
|
||||
{
|
||||
{
|
||||
if (itr->first != guid)
|
||||
{
|
||||
if (itr->second.bestCompatible.hasGuid(guid))
|
||||
{
|
||||
//sLog->outString("CLEAR bestCompatible: %s, because of guid: %u", itr->second.bestCompatible.toString().c_str(), GUID_LOPART(guid));
|
||||
{
|
||||
//sLog->outString("CLEAR bestCompatible: %s, because of guid: %u", itr->second.bestCompatible.toString().c_str(), GUID_LOPART(guid));
|
||||
itr->second.bestCompatible.clear();
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
//sLog->outString("CLEAR bestCompatible SELF: %s, because of guid: %u", itr->second.bestCompatible.toString().c_str(), GUID_LOPART(guid));
|
||||
//itr->second.bestCompatible.clear(); // don't clear here, because UpdateQueueTimers will try to find with every diff update
|
||||
{
|
||||
//sLog->outString("CLEAR bestCompatible SELF: %s, because of guid: %u", itr->second.bestCompatible.toString().c_str(), GUID_LOPART(guid));
|
||||
//itr->second.bestCompatible.clear(); // don't clear here, because UpdateQueueTimers will try to find with every diff update
|
||||
itDelete = itr;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// xinef: partial
|
||||
// xinef: partial
|
||||
if (!partial && itDelete != QueueDataStore.end())
|
||||
{
|
||||
//sLog->outString("ERASE QueueDataStore for: %u", GUID_LOPART(guid));
|
||||
//sLog->outString("ERASE QueueDataStore for: %u, itDelete: %u,%u,%u", GUID_LOPART(guid), itDelete->second.dps, itDelete->second.healers, itDelete->second.tanks);
|
||||
{
|
||||
//sLog->outString("ERASE QueueDataStore for: %u", GUID_LOPART(guid));
|
||||
//sLog->outString("ERASE QueueDataStore for: %u, itDelete: %u,%u,%u", GUID_LOPART(guid), itDelete->second.dps, itDelete->second.healers, itDelete->second.tanks);
|
||||
QueueDataStore.erase(itDelete);
|
||||
//sLog->outString("ERASE QueueDataStore for: %u SUCCESS", GUID_LOPART(guid));
|
||||
}
|
||||
//sLog->outString("ERASE QueueDataStore for: %u SUCCESS", GUID_LOPART(guid));
|
||||
}
|
||||
}
|
||||
|
||||
void LFGQueue::AddToNewQueue(uint64 guid, bool front)
|
||||
{
|
||||
if (front)
|
||||
{
|
||||
//sLog->outString("ADD AddToNewQueue at FRONT: %u", GUID_LOPART(guid));
|
||||
restoredAfterProposal.push_back(guid);
|
||||
{
|
||||
//sLog->outString("ADD AddToNewQueue at FRONT: %u", GUID_LOPART(guid));
|
||||
restoredAfterProposal.push_back(guid);
|
||||
newToQueueStore.push_front(guid);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
//sLog->outString("ADD AddToNewQueue at the END: %u", GUID_LOPART(guid));
|
||||
{
|
||||
//sLog->outString("ADD AddToNewQueue at the END: %u", GUID_LOPART(guid));
|
||||
newToQueueStore.push_back(guid);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void LFGQueue::RemoveFromNewQueue(uint64 guid)
|
||||
{
|
||||
//sLog->outString("REMOVE RemoveFromNewQueue: %u", GUID_LOPART(guid));
|
||||
//sLog->outString("REMOVE RemoveFromNewQueue: %u", GUID_LOPART(guid));
|
||||
newToQueueStore.remove(guid);
|
||||
restoredAfterProposal.remove(guid);
|
||||
restoredAfterProposal.remove(guid);
|
||||
}
|
||||
|
||||
void LFGQueue::AddQueueData(uint64 guid, time_t joinTime, LfgDungeonSet const& dungeons, LfgRolesMap const& rolesMap)
|
||||
{
|
||||
//sLog->outString("JOINED AddQueueData: %u", GUID_LOPART(guid));
|
||||
//sLog->outString("JOINED AddQueueData: %u", GUID_LOPART(guid));
|
||||
QueueDataStore[guid] = LfgQueueData(joinTime, dungeons, rolesMap);
|
||||
AddToQueue(guid);
|
||||
}
|
||||
|
||||
void LFGQueue::RemoveQueueData(uint64 guid)
|
||||
{
|
||||
//sLog->outString("LEFT RemoveQueueData: %u", GUID_LOPART(guid));
|
||||
//sLog->outString("LEFT RemoveQueueData: %u", GUID_LOPART(guid));
|
||||
LfgQueueDataContainer::iterator it = QueueDataStore.find(guid);
|
||||
if (it != QueueDataStore.end())
|
||||
QueueDataStore.erase(it);
|
||||
@@ -145,73 +145,73 @@ void LFGQueue::UpdateWaitTimeDps(int32 waitTime, uint32 dungeonId)
|
||||
|
||||
void LFGQueue::RemoveFromCompatibles(uint64 guid)
|
||||
{
|
||||
//sLog->outString("COMPATIBLES REMOVE for: %u", GUID_LOPART(guid));
|
||||
//sLog->outString("COMPATIBLES REMOVE for: %u", GUID_LOPART(guid));
|
||||
for (LfgCompatibleContainer::iterator it = CompatibleList.begin(); it != CompatibleList.end(); ++it)
|
||||
if (it->hasGuid(guid))
|
||||
{
|
||||
//sLog->outString("Removed Compatible: %s, because of guid: %u", it->toString().c_str(), GUID_LOPART(guid));
|
||||
{
|
||||
//sLog->outString("Removed Compatible: %s, because of guid: %u", it->toString().c_str(), GUID_LOPART(guid));
|
||||
it->clear(); // set to 0, this will be removed while iterating in FindNewGroups
|
||||
}
|
||||
}
|
||||
for (LfgCompatibleContainer::iterator itr = CompatibleTempList.begin(); itr != CompatibleTempList.end(); )
|
||||
{
|
||||
LfgCompatibleContainer::iterator it = itr++;
|
||||
{
|
||||
LfgCompatibleContainer::iterator it = itr++;
|
||||
if (it->hasGuid(guid))
|
||||
{
|
||||
//sLog->outString("Erased Temp Compatible: %s, because of guid: %u", it->toString().c_str(), GUID_LOPART(guid));
|
||||
{
|
||||
//sLog->outString("Erased Temp Compatible: %s, because of guid: %u", it->toString().c_str(), GUID_LOPART(guid));
|
||||
CompatibleTempList.erase(it);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void LFGQueue::AddToCompatibles(Lfg5Guids const& key)
|
||||
{
|
||||
//sLog->outString("COMPATIBLES ADD: %s", key.toString().c_str());
|
||||
//sLog->outString("COMPATIBLES ADD: %s", key.toString().c_str());
|
||||
CompatibleTempList.push_back(key);
|
||||
}
|
||||
|
||||
uint8 LFGQueue::FindGroups()
|
||||
{
|
||||
//sLog->outString("FIND GROUPS!");
|
||||
uint8 newGroupsProcessed = 0;
|
||||
//sLog->outString("FIND GROUPS!");
|
||||
uint8 newGroupsProcessed = 0;
|
||||
while (!newToQueueStore.empty())
|
||||
{
|
||||
++newGroupsProcessed;
|
||||
++newGroupsProcessed;
|
||||
uint64 newGuid = newToQueueStore.front();
|
||||
bool pushCompatiblesToFront = (std::find(restoredAfterProposal.begin(), restoredAfterProposal.end(), newGuid) != restoredAfterProposal.end());
|
||||
//sLog->outString("newToQueueStore guid: %u, front: %u", GUID_LOPART(newGuid), pushCompatiblesToFront ? 1 : 0);
|
||||
bool pushCompatiblesToFront = (std::find(restoredAfterProposal.begin(), restoredAfterProposal.end(), newGuid) != restoredAfterProposal.end());
|
||||
//sLog->outString("newToQueueStore guid: %u, front: %u", GUID_LOPART(newGuid), pushCompatiblesToFront ? 1 : 0);
|
||||
RemoveFromNewQueue(newGuid);
|
||||
|
||||
FindNewGroups(newGuid);
|
||||
|
||||
CompatibleList.splice((pushCompatiblesToFront ? CompatibleList.begin() : CompatibleList.end()), CompatibleTempList);
|
||||
CompatibleTempList.clear();
|
||||
CompatibleList.splice((pushCompatiblesToFront ? CompatibleList.begin() : CompatibleList.end()), CompatibleTempList);
|
||||
CompatibleTempList.clear();
|
||||
|
||||
return newGroupsProcessed; // pussywizard: only one per update, shouldn't be a problem
|
||||
return newGroupsProcessed; // pussywizard: only one per update, shouldn't be a problem
|
||||
}
|
||||
return newGroupsProcessed;
|
||||
}
|
||||
|
||||
LfgCompatibility LFGQueue::FindNewGroups(const uint64& newGuid)
|
||||
{
|
||||
// each combination of dps+heal+tank (tank*8 + heal+4 + dps) has a value assigned 0..15
|
||||
// first 16 bits of the mask are for marking if such combination was found once, second 16 bits for marking second occurence of that combination, etc
|
||||
uint64 foundMask = 0;
|
||||
uint32 foundCount = 0;
|
||||
// each combination of dps+heal+tank (tank*8 + heal+4 + dps) has a value assigned 0..15
|
||||
// first 16 bits of the mask are for marking if such combination was found once, second 16 bits for marking second occurence of that combination, etc
|
||||
uint64 foundMask = 0;
|
||||
uint32 foundCount = 0;
|
||||
|
||||
//sLog->outString("FIND NEW GROUPS for: %u", GUID_LOPART(newGuid));
|
||||
//sLog->outString("FIND NEW GROUPS for: %u", GUID_LOPART(newGuid));
|
||||
|
||||
// we have to take into account that FindNewGroups is called every X minutes if number of compatibles is low!
|
||||
// build set of already present compatibles for this guid
|
||||
std::set<Lfg5Guids> currentCompatibles;
|
||||
for (Lfg5GuidsList::iterator it = CompatibleList.begin(); it != CompatibleList.end(); ++it)
|
||||
if (it->hasGuid(newGuid))
|
||||
{
|
||||
// unset roles here so they are not copied, restore after insertion
|
||||
LfgRolesMap* r = it->roles;
|
||||
it->roles = NULL;
|
||||
currentCompatibles.insert(*it);
|
||||
it->roles = r;
|
||||
}
|
||||
// we have to take into account that FindNewGroups is called every X minutes if number of compatibles is low!
|
||||
// build set of already present compatibles for this guid
|
||||
std::set<Lfg5Guids> currentCompatibles;
|
||||
for (Lfg5GuidsList::iterator it = CompatibleList.begin(); it != CompatibleList.end(); ++it)
|
||||
if (it->hasGuid(newGuid))
|
||||
{
|
||||
// unset roles here so they are not copied, restore after insertion
|
||||
LfgRolesMap* r = it->roles;
|
||||
it->roles = NULL;
|
||||
currentCompatibles.insert(*it);
|
||||
it->roles = r;
|
||||
}
|
||||
|
||||
LfgCompatibility selfCompatibility = LFG_COMPATIBILITY_PENDING;
|
||||
if (currentCompatibles.empty())
|
||||
@@ -221,35 +221,35 @@ LfgCompatibility LFGQueue::FindNewGroups(const uint64& newGuid)
|
||||
return selfCompatibility;
|
||||
}
|
||||
|
||||
for (Lfg5GuidsList::iterator it = CompatibleList.begin(); it != CompatibleList.end(); )
|
||||
{
|
||||
Lfg5GuidsList::iterator itr = it++;
|
||||
if (itr->empty())
|
||||
{
|
||||
//sLog->outString("ERASE from CompatibleList");
|
||||
CompatibleList.erase(itr);
|
||||
continue;
|
||||
}
|
||||
LfgCompatibility compatibility = CheckCompatibility(*itr, newGuid, foundMask, foundCount, currentCompatibles);
|
||||
if (compatibility == LFG_COMPATIBLES_MATCH)
|
||||
return LFG_COMPATIBLES_MATCH;
|
||||
if ((foundMask & 0x3FFF3FFF3FFF3FFF) == 0x3FFF3FFF3FFF3FFF) // each combination of dps+heal+tank already found 4 times
|
||||
break;
|
||||
}
|
||||
for (Lfg5GuidsList::iterator it = CompatibleList.begin(); it != CompatibleList.end(); )
|
||||
{
|
||||
Lfg5GuidsList::iterator itr = it++;
|
||||
if (itr->empty())
|
||||
{
|
||||
//sLog->outString("ERASE from CompatibleList");
|
||||
CompatibleList.erase(itr);
|
||||
continue;
|
||||
}
|
||||
LfgCompatibility compatibility = CheckCompatibility(*itr, newGuid, foundMask, foundCount, currentCompatibles);
|
||||
if (compatibility == LFG_COMPATIBLES_MATCH)
|
||||
return LFG_COMPATIBLES_MATCH;
|
||||
if ((foundMask & 0x3FFF3FFF3FFF3FFF) == 0x3FFF3FFF3FFF3FFF) // each combination of dps+heal+tank already found 4 times
|
||||
break;
|
||||
}
|
||||
|
||||
return selfCompatibility;
|
||||
}
|
||||
|
||||
LfgCompatibility LFGQueue::CheckCompatibility(Lfg5Guids const& checkWith, const uint64& newGuid, uint64& foundMask, uint32& foundCount, const std::set<Lfg5Guids>& currentCompatibles)
|
||||
{
|
||||
//sLog->outString("CHECK CheckCompatibility: %s, new guid: %u", checkWith.toString().c_str(), GUID_LOPART(newGuid));
|
||||
Lfg5Guids check(checkWith, false); // here newGuid is at front
|
||||
Lfg5Guids strGuids(checkWith, false); // here guids are sorted
|
||||
check.force_insert_front(newGuid);
|
||||
strGuids.insert(newGuid);
|
||||
//sLog->outString("CHECK CheckCompatibility: %s, new guid: %u", checkWith.toString().c_str(), GUID_LOPART(newGuid));
|
||||
Lfg5Guids check(checkWith, false); // here newGuid is at front
|
||||
Lfg5Guids strGuids(checkWith, false); // here guids are sorted
|
||||
check.force_insert_front(newGuid);
|
||||
strGuids.insert(newGuid);
|
||||
|
||||
if (!currentCompatibles.empty() && currentCompatibles.find(strGuids) != currentCompatibles.end())
|
||||
return LFG_INCOMPATIBLES_TOO_MUCH_PLAYERS;
|
||||
if (!currentCompatibles.empty() && currentCompatibles.find(strGuids) != currentCompatibles.end())
|
||||
return LFG_INCOMPATIBLES_TOO_MUCH_PLAYERS;
|
||||
|
||||
LfgProposal proposal;
|
||||
LfgDungeonSet proposalDungeons;
|
||||
@@ -259,10 +259,10 @@ LfgCompatibility LFGQueue::CheckCompatibility(Lfg5Guids const& checkWith, const
|
||||
// Check if more than one LFG group and number of players joining
|
||||
uint8 numPlayers = 0;
|
||||
uint8 numLfgGroups = 0;
|
||||
uint64 guid;
|
||||
uint64 addToFoundMask = 0;
|
||||
uint64 guid;
|
||||
uint64 addToFoundMask = 0;
|
||||
|
||||
for (uint8 i=0; i<5 && (guid=check.guid[i]) != 0 && numLfgGroups < 2 && numPlayers <= MAXGROUPSIZE; ++i)
|
||||
for (uint8 i=0; i<5 && (guid=check.guid[i]) != 0 && numLfgGroups < 2 && numPlayers <= MAXGROUPSIZE; ++i)
|
||||
{
|
||||
LfgQueueDataContainer::iterator itQueue = QueueDataStore.find(guid);
|
||||
if (itQueue == QueueDataStore.end())
|
||||
@@ -293,14 +293,14 @@ LfgCompatibility LFGQueue::CheckCompatibility(Lfg5Guids const& checkWith, const
|
||||
if (check.size() == 1 && numPlayers < MAXGROUPSIZE)
|
||||
{
|
||||
LfgQueueDataContainer::iterator itQueue = QueueDataStore.find(check.front());
|
||||
LfgRolesMap roles = itQueue->second.roles;
|
||||
LfgRolesMap roles = itQueue->second.roles;
|
||||
uint8 roleCheckResult = LFGMgr::CheckGroupRoles(roles);
|
||||
strGuids.addRoles(roles);
|
||||
itQueue->second.bestCompatible.clear(); // this may be left after a failed proposal (not cleared, because UpdateQueueTimers would try to generate it with every update)
|
||||
strGuids.addRoles(roles);
|
||||
itQueue->second.bestCompatible.clear(); // this may be left after a failed proposal (not cleared, because UpdateQueueTimers would try to generate it with every update)
|
||||
//UpdateBestCompatibleInQueue(itQueue, strGuids);
|
||||
AddToCompatibles(strGuids);
|
||||
if (roleCheckResult && roleCheckResult <= 15)
|
||||
foundMask |= ( (((uint64)1)<<(roleCheckResult-1)) | (((uint64)1)<<(16+roleCheckResult-1)) | (((uint64)1)<<(32+roleCheckResult-1)) | (((uint64)1)<<(48+roleCheckResult-1)) );
|
||||
if (roleCheckResult && roleCheckResult <= 15)
|
||||
foundMask |= ( (((uint64)1)<<(roleCheckResult-1)) | (((uint64)1)<<(16+roleCheckResult-1)) | (((uint64)1)<<(32+roleCheckResult-1)) | (((uint64)1)<<(48+roleCheckResult-1)) );
|
||||
return LFG_COMPATIBLES_WITH_LESS_PLAYERS;
|
||||
}
|
||||
|
||||
@@ -310,7 +310,7 @@ LfgCompatibility LFGQueue::CheckCompatibility(Lfg5Guids const& checkWith, const
|
||||
// If it's single group no need to check for duplicate players, ignores, bad roles or bad dungeons as it's been checked before joining
|
||||
if (check.size() > 1)
|
||||
{
|
||||
for (uint8 i=0; i<5 && check.guid[i]; ++i)
|
||||
for (uint8 i=0; i<5 && check.guid[i]; ++i)
|
||||
{
|
||||
const LfgRolesMap &roles = QueueDataStore[check.guid[i]].roles;
|
||||
for (LfgRolesMap::const_iterator itRoles = roles.begin(); itRoles != roles.end(); ++itRoles)
|
||||
@@ -319,51 +319,51 @@ LfgCompatibility LFGQueue::CheckCompatibility(Lfg5Guids const& checkWith, const
|
||||
for (itPlayer = proposalRoles.begin(); itPlayer != proposalRoles.end(); ++itPlayer)
|
||||
{
|
||||
if (itRoles->first == itPlayer->first)
|
||||
{
|
||||
// pussywizard: LFG ZOMG! this means that this player was in two different LfgQueueData (in QueueDataStore), and at least one of them is a group guid, because we do checks so there aren't 2 same guids in current CHECK
|
||||
{
|
||||
// pussywizard: LFG ZOMG! this means that this player was in two different LfgQueueData (in QueueDataStore), and at least one of them is a group guid, because we do checks so there aren't 2 same guids in current CHECK
|
||||
//sLog->outError("LFGQueue::CheckCompatibility: ERROR! Player multiple times in queue! [" UI64FMTD "]", itRoles->first);
|
||||
break;
|
||||
}
|
||||
break;
|
||||
}
|
||||
else if (sLFGMgr->HasIgnore(itRoles->first, itPlayer->first))
|
||||
break;
|
||||
}
|
||||
if (itPlayer == proposalRoles.end())
|
||||
proposalRoles[itRoles->first] = itRoles->second;
|
||||
else
|
||||
break;
|
||||
else
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (numPlayers != proposalRoles.size())
|
||||
return LFG_INCOMPATIBLES_HAS_IGNORES;
|
||||
|
||||
uint8 roleCheckResult = LFGMgr::CheckGroupRoles(proposalRoles);
|
||||
uint8 roleCheckResult = LFGMgr::CheckGroupRoles(proposalRoles);
|
||||
if (!roleCheckResult || roleCheckResult > 0xF)
|
||||
return LFG_INCOMPATIBLES_NO_ROLES;
|
||||
|
||||
// now, every combination can occur only 4 times (explained in FindNewGroups)
|
||||
if (foundMask & (((uint64)1)<<(roleCheckResult-1)))
|
||||
{
|
||||
if (foundMask & (((uint64)1)<<(16+roleCheckResult-1)))
|
||||
{
|
||||
if (foundMask & (((uint64)1)<<(32+roleCheckResult-1)))
|
||||
{
|
||||
if (foundMask & (((uint64)1)<<(48+roleCheckResult-1)))
|
||||
{
|
||||
if (foundCount >= 10) // but only after finding at least 10 compatibles (this helps when there are few groups)
|
||||
return LFG_INCOMPATIBLES_NO_ROLES;
|
||||
}
|
||||
else
|
||||
addToFoundMask |= (((uint64)1)<<(48+roleCheckResult-1));
|
||||
}
|
||||
else
|
||||
addToFoundMask |= (((uint64)1)<<(32+roleCheckResult-1));
|
||||
}
|
||||
else
|
||||
addToFoundMask |= (((uint64)1)<<(16+roleCheckResult-1));
|
||||
}
|
||||
else
|
||||
addToFoundMask |= (((uint64)1)<<(roleCheckResult-1));
|
||||
// now, every combination can occur only 4 times (explained in FindNewGroups)
|
||||
if (foundMask & (((uint64)1)<<(roleCheckResult-1)))
|
||||
{
|
||||
if (foundMask & (((uint64)1)<<(16+roleCheckResult-1)))
|
||||
{
|
||||
if (foundMask & (((uint64)1)<<(32+roleCheckResult-1)))
|
||||
{
|
||||
if (foundMask & (((uint64)1)<<(48+roleCheckResult-1)))
|
||||
{
|
||||
if (foundCount >= 10) // but only after finding at least 10 compatibles (this helps when there are few groups)
|
||||
return LFG_INCOMPATIBLES_NO_ROLES;
|
||||
}
|
||||
else
|
||||
addToFoundMask |= (((uint64)1)<<(48+roleCheckResult-1));
|
||||
}
|
||||
else
|
||||
addToFoundMask |= (((uint64)1)<<(32+roleCheckResult-1));
|
||||
}
|
||||
else
|
||||
addToFoundMask |= (((uint64)1)<<(16+roleCheckResult-1));
|
||||
}
|
||||
else
|
||||
addToFoundMask |= (((uint64)1)<<(roleCheckResult-1));
|
||||
|
||||
proposalDungeons = QueueDataStore[check.front()].dungeons;
|
||||
for (uint8 i=1; i<5 && check.guid[i]; ++i)
|
||||
@@ -379,7 +379,7 @@ LfgCompatibility LFGQueue::CheckCompatibility(Lfg5Guids const& checkWith, const
|
||||
}
|
||||
else
|
||||
{
|
||||
uint64 gguid = check.front();
|
||||
uint64 gguid = check.front();
|
||||
const LfgQueueData &queue = QueueDataStore[gguid];
|
||||
proposalDungeons = queue.dungeons;
|
||||
proposalRoles = queue.roles;
|
||||
@@ -389,16 +389,16 @@ LfgCompatibility LFGQueue::CheckCompatibility(Lfg5Guids const& checkWith, const
|
||||
// Enough players?
|
||||
if (numPlayers != MAXGROUPSIZE)
|
||||
{
|
||||
strGuids.addRoles(proposalRoles);
|
||||
for (uint8 i=0; i<5 && check.guid[i]; ++i)
|
||||
{
|
||||
LfgQueueDataContainer::iterator itr = QueueDataStore.find(check.guid[i]);
|
||||
if (!itr->second.bestCompatible.empty()) // update if groups don't have it empty (for empty it will be generated in UpdateQueueTimers)
|
||||
UpdateBestCompatibleInQueue(itr, strGuids);
|
||||
}
|
||||
strGuids.addRoles(proposalRoles);
|
||||
for (uint8 i=0; i<5 && check.guid[i]; ++i)
|
||||
{
|
||||
LfgQueueDataContainer::iterator itr = QueueDataStore.find(check.guid[i]);
|
||||
if (!itr->second.bestCompatible.empty()) // update if groups don't have it empty (for empty it will be generated in UpdateQueueTimers)
|
||||
UpdateBestCompatibleInQueue(itr, strGuids);
|
||||
}
|
||||
AddToCompatibles(strGuids);
|
||||
foundMask |= addToFoundMask;
|
||||
++foundCount;
|
||||
foundMask |= addToFoundMask;
|
||||
++foundCount;
|
||||
return LFG_COMPATIBLES_WITH_LESS_PLAYERS;
|
||||
}
|
||||
|
||||
@@ -436,8 +436,8 @@ LfgCompatibility LFGQueue::CheckCompatibility(Lfg5Guids const& checkWith, const
|
||||
data.accept = LFG_ANSWER_AGREE;
|
||||
}
|
||||
|
||||
for (uint8 i=0; i<5 && proposal.queues.guid[i]; ++i)
|
||||
RemoveFromQueue(proposal.queues.guid[i], true);
|
||||
for (uint8 i=0; i<5 && proposal.queues.guid[i]; ++i)
|
||||
RemoveFromQueue(proposal.queues.guid[i], true);
|
||||
|
||||
sLFGMgr->AddProposal(proposal);
|
||||
|
||||
@@ -446,52 +446,52 @@ LfgCompatibility LFGQueue::CheckCompatibility(Lfg5Guids const& checkWith, const
|
||||
|
||||
void LFGQueue::UpdateQueueTimers(uint32 diff)
|
||||
{
|
||||
time_t currTime = time(NULL);
|
||||
bool sendQueueStatus = false;
|
||||
time_t currTime = time(NULL);
|
||||
bool sendQueueStatus = false;
|
||||
|
||||
if (m_QueueStatusTimer > LFG_QUEUEUPDATE_INTERVAL)
|
||||
{
|
||||
m_QueueStatusTimer = 0;
|
||||
sendQueueStatus = true;
|
||||
}
|
||||
else
|
||||
m_QueueStatusTimer += diff;
|
||||
|
||||
//sLog->outString("UPDATE UpdateQueueTimers");
|
||||
for (Lfg5GuidsList::iterator it = CompatibleList.begin(); it != CompatibleList.end(); )
|
||||
if (m_QueueStatusTimer > LFG_QUEUEUPDATE_INTERVAL)
|
||||
{
|
||||
Lfg5GuidsList::iterator itr = it++;
|
||||
if (itr->empty())
|
||||
{
|
||||
//sLog->outString("UpdateQueueTimers ERASE compatible");
|
||||
CompatibleList.erase(itr);
|
||||
}
|
||||
}
|
||||
m_QueueStatusTimer = 0;
|
||||
sendQueueStatus = true;
|
||||
}
|
||||
else
|
||||
m_QueueStatusTimer += diff;
|
||||
|
||||
if (!sendQueueStatus)
|
||||
{
|
||||
for (LfgQueueDataContainer::iterator itQueue = QueueDataStore.begin(); itQueue != QueueDataStore.end(); )
|
||||
{
|
||||
if (currTime - itQueue->second.joinTime > 2*HOUR)
|
||||
{
|
||||
uint64 guid = itQueue->first;
|
||||
QueueDataStore.erase(itQueue++);
|
||||
sLFGMgr->LeaveAllLfgQueues(guid, true);
|
||||
continue;
|
||||
}
|
||||
if (itQueue->second.bestCompatible.empty())
|
||||
{
|
||||
uint32 numOfCompatibles = FindBestCompatibleInQueue(itQueue);
|
||||
if (numOfCompatibles /*must be positive, because proposals don't delete QueueQueueData*/ && currTime-itQueue->second.lastRefreshTime >= 60 && numOfCompatibles < (5-itQueue->second.bestCompatible.roles->size())*25)
|
||||
{
|
||||
itQueue->second.lastRefreshTime = currTime;
|
||||
AddToQueue(itQueue->first, false);
|
||||
}
|
||||
}
|
||||
++itQueue;
|
||||
}
|
||||
return;
|
||||
}
|
||||
//sLog->outString("UPDATE UpdateQueueTimers");
|
||||
for (Lfg5GuidsList::iterator it = CompatibleList.begin(); it != CompatibleList.end(); )
|
||||
{
|
||||
Lfg5GuidsList::iterator itr = it++;
|
||||
if (itr->empty())
|
||||
{
|
||||
//sLog->outString("UpdateQueueTimers ERASE compatible");
|
||||
CompatibleList.erase(itr);
|
||||
}
|
||||
}
|
||||
|
||||
if (!sendQueueStatus)
|
||||
{
|
||||
for (LfgQueueDataContainer::iterator itQueue = QueueDataStore.begin(); itQueue != QueueDataStore.end(); )
|
||||
{
|
||||
if (currTime - itQueue->second.joinTime > 2*HOUR)
|
||||
{
|
||||
uint64 guid = itQueue->first;
|
||||
QueueDataStore.erase(itQueue++);
|
||||
sLFGMgr->LeaveAllLfgQueues(guid, true);
|
||||
continue;
|
||||
}
|
||||
if (itQueue->second.bestCompatible.empty())
|
||||
{
|
||||
uint32 numOfCompatibles = FindBestCompatibleInQueue(itQueue);
|
||||
if (numOfCompatibles /*must be positive, because proposals don't delete QueueQueueData*/ && currTime-itQueue->second.lastRefreshTime >= 60 && numOfCompatibles < (5-itQueue->second.bestCompatible.roles->size())*25)
|
||||
{
|
||||
itQueue->second.lastRefreshTime = currTime;
|
||||
AddToQueue(itQueue->first, false);
|
||||
}
|
||||
}
|
||||
++itQueue;
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
//sLog->outTrace(LOG_FILTER_LFG, "Updating queue timers...");
|
||||
for (LfgQueueDataContainer::iterator itQueue = QueueDataStore.begin(); itQueue != QueueDataStore.end(); ++itQueue)
|
||||
@@ -530,10 +530,10 @@ void LFGQueue::UpdateQueueTimers(uint32 diff)
|
||||
}
|
||||
|
||||
if (queueinfo.bestCompatible.empty())
|
||||
{
|
||||
//sLog->outString("found empty bestCompatible");
|
||||
{
|
||||
//sLog->outString("found empty bestCompatible");
|
||||
FindBestCompatibleInQueue(itQueue);
|
||||
}
|
||||
}
|
||||
|
||||
LfgQueueStatusData queueData(dungeonId, waitTime, wtAvg, wtTank, wtHealer, wtDps, queuedTime, queueinfo.tanks, queueinfo.healers, queueinfo.dps);
|
||||
for (LfgRolesMap::const_iterator itPlayer = queueinfo.roles.begin(); itPlayer != queueinfo.roles.end(); ++itPlayer)
|
||||
@@ -551,19 +551,19 @@ time_t LFGQueue::GetJoinTime(uint64 guid)
|
||||
|
||||
uint32 LFGQueue::FindBestCompatibleInQueue(LfgQueueDataContainer::iterator itrQueue)
|
||||
{
|
||||
uint32 numOfCompatibles = 0;
|
||||
uint32 numOfCompatibles = 0;
|
||||
for (LfgCompatibleContainer::const_iterator itr = CompatibleList.begin(); itr != CompatibleList.end(); ++itr)
|
||||
if (itr->hasGuid(itrQueue->first))
|
||||
{
|
||||
++numOfCompatibles;
|
||||
{
|
||||
++numOfCompatibles;
|
||||
UpdateBestCompatibleInQueue(itrQueue, *itr);
|
||||
}
|
||||
return numOfCompatibles;
|
||||
}
|
||||
return numOfCompatibles;
|
||||
}
|
||||
|
||||
void LFGQueue::UpdateBestCompatibleInQueue(LfgQueueDataContainer::iterator itrQueue, Lfg5Guids const& key)
|
||||
{
|
||||
//sLog->outString("UpdateBestCompatibleInQueue: %s", key.toString().c_str());
|
||||
//sLog->outString("UpdateBestCompatibleInQueue: %s", key.toString().c_str());
|
||||
LfgQueueData& queueData = itrQueue->second;
|
||||
|
||||
uint8 storedSize = queueData.bestCompatible.size();
|
||||
|
||||
Reference in New Issue
Block a user