mirror of
https://github.com/TrinityCore/TrinityCore.git
synced 2026-02-19 08:30:34 +01:00
Core/Entities: Use ObjectGuid class in game project
This commit is contained in:
@@ -36,20 +36,20 @@ namespace lfg
|
||||
@param[in] check list of guids
|
||||
@returns Concatenated string
|
||||
*/
|
||||
std::string ConcatenateGuids(LfgGuidList const& check)
|
||||
std::string ConcatenateGuids(GuidList const& check)
|
||||
{
|
||||
if (check.empty())
|
||||
return "";
|
||||
|
||||
// need the guids in order to avoid duplicates
|
||||
LfgGuidSet guids(check.begin(), check.end());
|
||||
GuidSet guids(check.begin(), check.end());
|
||||
|
||||
std::ostringstream o;
|
||||
|
||||
LfgGuidSet::const_iterator it = guids.begin();
|
||||
o << (*it);
|
||||
GuidSet::const_iterator it = guids.begin();
|
||||
o << it->GetRawValue();
|
||||
for (++it; it != guids.end(); ++it)
|
||||
o << '|' << (*it);
|
||||
o << '|' << it->GetRawValue();
|
||||
|
||||
return o.str();
|
||||
}
|
||||
@@ -83,7 +83,7 @@ char const* GetCompatibleString(LfgCompatibility compatibles)
|
||||
}
|
||||
}
|
||||
|
||||
void LFGQueue::AddToQueue(uint64 guid)
|
||||
void LFGQueue::AddToQueue(ObjectGuid guid)
|
||||
{
|
||||
LfgQueueDataContainer::iterator itQueue = QueueDataStore.find(guid);
|
||||
if (itQueue == QueueDataStore.end())
|
||||
@@ -95,14 +95,14 @@ void LFGQueue::AddToQueue(uint64 guid)
|
||||
AddToNewQueue(guid);
|
||||
}
|
||||
|
||||
void LFGQueue::RemoveFromQueue(uint64 guid)
|
||||
void LFGQueue::RemoveFromQueue(ObjectGuid guid)
|
||||
{
|
||||
RemoveFromNewQueue(guid);
|
||||
RemoveFromCurrentQueue(guid);
|
||||
RemoveFromCompatibles(guid);
|
||||
|
||||
std::ostringstream o;
|
||||
o << guid;
|
||||
o << guid.GetRawValue();
|
||||
std::string sguid = o.str();
|
||||
|
||||
LfgQueueDataContainer::iterator itDelete = QueueDataStore.end();
|
||||
@@ -122,33 +122,33 @@ void LFGQueue::RemoveFromQueue(uint64 guid)
|
||||
QueueDataStore.erase(itDelete);
|
||||
}
|
||||
|
||||
void LFGQueue::AddToNewQueue(uint64 guid)
|
||||
void LFGQueue::AddToNewQueue(ObjectGuid guid)
|
||||
{
|
||||
newToQueueStore.push_back(guid);
|
||||
}
|
||||
|
||||
void LFGQueue::RemoveFromNewQueue(uint64 guid)
|
||||
void LFGQueue::RemoveFromNewQueue(ObjectGuid guid)
|
||||
{
|
||||
newToQueueStore.remove(guid);
|
||||
}
|
||||
|
||||
void LFGQueue::AddToCurrentQueue(uint64 guid)
|
||||
void LFGQueue::AddToCurrentQueue(ObjectGuid guid)
|
||||
{
|
||||
currentQueueStore.push_back(guid);
|
||||
}
|
||||
|
||||
void LFGQueue::RemoveFromCurrentQueue(uint64 guid)
|
||||
void LFGQueue::RemoveFromCurrentQueue(ObjectGuid guid)
|
||||
{
|
||||
currentQueueStore.remove(guid);
|
||||
}
|
||||
|
||||
void LFGQueue::AddQueueData(uint64 guid, time_t joinTime, LfgDungeonSet const& dungeons, LfgRolesMap const& rolesMap)
|
||||
void LFGQueue::AddQueueData(ObjectGuid guid, time_t joinTime, LfgDungeonSet const& dungeons, LfgRolesMap const& rolesMap)
|
||||
{
|
||||
QueueDataStore[guid] = LfgQueueData(joinTime, dungeons, rolesMap);
|
||||
AddToQueue(guid);
|
||||
}
|
||||
|
||||
void LFGQueue::RemoveQueueData(uint64 guid)
|
||||
void LFGQueue::RemoveQueueData(ObjectGuid guid)
|
||||
{
|
||||
LfgQueueDataContainer::iterator it = QueueDataStore.find(guid);
|
||||
if (it != QueueDataStore.end())
|
||||
@@ -188,13 +188,13 @@ void LFGQueue::UpdateWaitTimeDps(int32 waitTime, uint32 dungeonId)
|
||||
|
||||
@param[in] guid Guid to remove from compatible cache
|
||||
*/
|
||||
void LFGQueue::RemoveFromCompatibles(uint64 guid)
|
||||
void LFGQueue::RemoveFromCompatibles(ObjectGuid guid)
|
||||
{
|
||||
std::stringstream out;
|
||||
out << guid;
|
||||
out << guid.GetRawValue();
|
||||
std::string strGuid = out.str();
|
||||
|
||||
TC_LOG_DEBUG("lfg.queue.data.compatibles.remove", "Removing [" UI64FMTD "]", guid);
|
||||
TC_LOG_DEBUG("lfg.queue.data.compatibles.remove", "Removing %s", guid.ToString().c_str());
|
||||
for (LfgCompatibleContainer::iterator itNext = CompatibleMapStore.begin(); itNext != CompatibleMapStore.end();)
|
||||
{
|
||||
LfgCompatibleContainer::iterator it = itNext++;
|
||||
@@ -247,16 +247,18 @@ LfgCompatibilityData* LFGQueue::GetCompatibilityData(std::string const& key)
|
||||
uint8 LFGQueue::FindGroups()
|
||||
{
|
||||
uint8 proposals = 0;
|
||||
LfgGuidList firstNew;
|
||||
GuidList firstNew;
|
||||
while (!newToQueueStore.empty())
|
||||
{
|
||||
uint64 frontguid = newToQueueStore.front();
|
||||
TC_LOG_DEBUG("lfg.queue.match.check.new", "Checking [" UI64FMTD "] newToQueue(%u), currentQueue(%u)", frontguid, uint32(newToQueueStore.size()), uint32(currentQueueStore.size()));
|
||||
ObjectGuid frontguid = newToQueueStore.front();
|
||||
TC_LOG_DEBUG("lfg.queue.match.check.new", "Checking [%s] newToQueue(%u), currentQueue(%u)", frontguid.ToString().c_str(),
|
||||
uint32(newToQueueStore.size()), uint32(currentQueueStore.size()));
|
||||
|
||||
firstNew.clear();
|
||||
firstNew.push_back(frontguid);
|
||||
RemoveFromNewQueue(frontguid);
|
||||
|
||||
LfgGuidList temporalList = currentQueueStore;
|
||||
GuidList temporalList = currentQueueStore;
|
||||
LfgCompatibility compatibles = FindNewGroups(firstNew, temporalList);
|
||||
|
||||
if (compatibles == LFG_COMPATIBLES_MATCH)
|
||||
@@ -274,7 +276,7 @@ uint8 LFGQueue::FindGroups()
|
||||
@param[in] all List of all other guids in main queue to match against
|
||||
@return LfgCompatibility type of compatibility between groups
|
||||
*/
|
||||
LfgCompatibility LFGQueue::FindNewGroups(LfgGuidList& check, LfgGuidList& all)
|
||||
LfgCompatibility LFGQueue::FindNewGroups(GuidList& check, GuidList& all)
|
||||
{
|
||||
std::string strGuids = ConcatenateGuids(check);
|
||||
LfgCompatibility compatibles = GetCompatibles(strGuids);
|
||||
@@ -312,7 +314,7 @@ LfgCompatibility LFGQueue::FindNewGroups(LfgGuidList& check, LfgGuidList& all)
|
||||
@param[in] check List of guids to check compatibilities
|
||||
@return LfgCompatibility type of compatibility
|
||||
*/
|
||||
LfgCompatibility LFGQueue::CheckCompatibility(LfgGuidList check)
|
||||
LfgCompatibility LFGQueue::CheckCompatibility(GuidList check)
|
||||
{
|
||||
std::string strGuids = ConcatenateGuids(check);
|
||||
LfgProposal proposal;
|
||||
@@ -330,7 +332,7 @@ LfgCompatibility LFGQueue::CheckCompatibility(LfgGuidList check)
|
||||
// Check all-but-new compatiblitity
|
||||
if (check.size() > 2)
|
||||
{
|
||||
uint64 frontGuid = check.front();
|
||||
ObjectGuid frontGuid = check.front();
|
||||
check.pop_front();
|
||||
|
||||
// Check all-but-new compatibilities (New, A, B, C, D) --> check(A, B, C, D)
|
||||
@@ -347,20 +349,20 @@ LfgCompatibility LFGQueue::CheckCompatibility(LfgGuidList check)
|
||||
// Check if more than one LFG group and number of players joining
|
||||
uint8 numPlayers = 0;
|
||||
uint8 numLfgGroups = 0;
|
||||
for (LfgGuidList::const_iterator it = check.begin(); it != check.end() && numLfgGroups < 2 && numPlayers <= MAXGROUPSIZE; ++it)
|
||||
for (GuidList::const_iterator it = check.begin(); it != check.end() && numLfgGroups < 2 && numPlayers <= MAXGROUPSIZE; ++it)
|
||||
{
|
||||
uint64 guid = (*it);
|
||||
ObjectGuid guid = *it;
|
||||
LfgQueueDataContainer::iterator itQueue = QueueDataStore.find(guid);
|
||||
if (itQueue == QueueDataStore.end())
|
||||
{
|
||||
TC_LOG_ERROR("lfg.queue.match.compatibility.check", "Guid: [" UI64FMTD "] is not queued but listed as queued!", guid);
|
||||
TC_LOG_ERROR("lfg.queue.match.compatibility.check", "Guid: [%s] is not queued but listed as queued!", guid.ToString().c_str());
|
||||
RemoveFromQueue(guid);
|
||||
return LFG_COMPATIBILITY_PENDING;
|
||||
}
|
||||
|
||||
// Store group so we don't need to call Mgr to get it later (if it's player group will be 0 otherwise would have joined as group)
|
||||
for (LfgRolesMap::const_iterator it2 = itQueue->second.roles.begin(); it2 != itQueue->second.roles.end(); ++it2)
|
||||
proposalGroups[it2->first] = IS_GROUP_GUID(itQueue->first) ? itQueue->first : 0;
|
||||
proposalGroups[it2->first] = itQueue->first.IsGroup() ? itQueue->first : ObjectGuid::Empty;
|
||||
|
||||
numPlayers += itQueue->second.roles.size();
|
||||
|
||||
@@ -404,9 +406,9 @@ LfgCompatibility LFGQueue::CheckCompatibility(LfgGuidList check)
|
||||
// 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 (LfgGuidList::const_iterator it = check.begin(); it != check.end(); ++it)
|
||||
for (GuidList::const_iterator it = check.begin(); it != check.end(); ++it)
|
||||
{
|
||||
const LfgRolesMap &roles = QueueDataStore[(*it)].roles;
|
||||
LfgRolesMap const& roles = QueueDataStore[(*it)].roles;
|
||||
for (LfgRolesMap::const_iterator itRoles = roles.begin(); itRoles != roles.end(); ++itRoles)
|
||||
{
|
||||
LfgRolesMap::const_iterator itPlayer;
|
||||
@@ -434,22 +436,22 @@ LfgCompatibility LFGQueue::CheckCompatibility(LfgGuidList check)
|
||||
{
|
||||
std::ostringstream o;
|
||||
for (LfgRolesMap::const_iterator it = debugRoles.begin(); it != debugRoles.end(); ++it)
|
||||
o << ", " << it->first << ": " << GetRolesString(it->second);
|
||||
o << ", " << it->first.GetRawValue() << ": " << GetRolesString(it->second);
|
||||
|
||||
TC_LOG_DEBUG("lfg.queue.match.compatibility.check", "Guids: (%s) Roles not compatible%s", strGuids.c_str(), o.str().c_str());
|
||||
SetCompatibles(strGuids, LFG_INCOMPATIBLES_NO_ROLES);
|
||||
return LFG_INCOMPATIBLES_NO_ROLES;
|
||||
}
|
||||
|
||||
LfgGuidList::iterator itguid = check.begin();
|
||||
GuidList::iterator itguid = check.begin();
|
||||
proposalDungeons = QueueDataStore[*itguid].dungeons;
|
||||
std::ostringstream o;
|
||||
o << ", " << *itguid << ": (" << ConcatenateDungeons(proposalDungeons) << ")";
|
||||
o << ", " << itguid->GetRawValue() << ": (" << ConcatenateDungeons(proposalDungeons) << ")";
|
||||
for (++itguid; itguid != check.end(); ++itguid)
|
||||
{
|
||||
LfgDungeonSet temporal;
|
||||
LfgDungeonSet &dungeons = QueueDataStore[*itguid].dungeons;
|
||||
o << ", " << *itguid << ": (" << ConcatenateDungeons(dungeons) << ")";
|
||||
LfgDungeonSet& dungeons = QueueDataStore[*itguid].dungeons;
|
||||
o << ", " << itguid->GetRawValue() << ": (" << ConcatenateDungeons(dungeons) << ")";
|
||||
std::set_intersection(proposalDungeons.begin(), proposalDungeons.end(), dungeons.begin(), dungeons.end(), std::inserter(temporal, temporal.begin()));
|
||||
proposalDungeons = temporal;
|
||||
}
|
||||
@@ -463,7 +465,7 @@ LfgCompatibility LFGQueue::CheckCompatibility(LfgGuidList check)
|
||||
}
|
||||
else
|
||||
{
|
||||
uint64 gguid = *check.begin();
|
||||
ObjectGuid gguid = *check.begin();
|
||||
const LfgQueueData &queue = QueueDataStore[gguid];
|
||||
proposalDungeons = queue.dungeons;
|
||||
proposalRoles = queue.roles;
|
||||
@@ -477,14 +479,14 @@ LfgCompatibility LFGQueue::CheckCompatibility(LfgGuidList check)
|
||||
LfgCompatibilityData data(LFG_COMPATIBLES_WITH_LESS_PLAYERS);
|
||||
data.roles = proposalRoles;
|
||||
|
||||
for (LfgGuidList::const_iterator itr = check.begin(); itr != check.end(); ++itr)
|
||||
for (GuidList::const_iterator itr = check.begin(); itr != check.end(); ++itr)
|
||||
UpdateBestCompatibleInQueue(QueueDataStore.find(*itr), strGuids, data.roles);
|
||||
|
||||
SetCompatibilityData(strGuids, data);
|
||||
return LFG_COMPATIBLES_WITH_LESS_PLAYERS;
|
||||
}
|
||||
|
||||
uint64 gguid = *check.begin();
|
||||
ObjectGuid gguid = *check.begin();
|
||||
proposal.queues = check;
|
||||
proposal.isNew = numLfgGroups != 1 || sLFGMgr->GetOldState(gguid) != LFG_STATE_DUNGEON;
|
||||
|
||||
@@ -498,7 +500,7 @@ LfgCompatibility LFGQueue::CheckCompatibility(LfgGuidList check)
|
||||
// Create a new proposal
|
||||
proposal.cancelTime = time(NULL) + LFG_TIME_PROPOSAL;
|
||||
proposal.state = LFG_PROPOSAL_INITIATING;
|
||||
proposal.leader = 0;
|
||||
proposal.leader.Clear();
|
||||
proposal.dungeonId = Trinity::Containers::SelectRandomContainerElement(proposalDungeons);
|
||||
|
||||
bool leader = false;
|
||||
@@ -523,9 +525,9 @@ LfgCompatibility LFGQueue::CheckCompatibility(LfgGuidList check)
|
||||
}
|
||||
|
||||
// Mark proposal members as not queued (but not remove queue data)
|
||||
for (LfgGuidList::const_iterator itQueue = proposal.queues.begin(); itQueue != proposal.queues.end(); ++itQueue)
|
||||
for (GuidList::const_iterator itQueue = proposal.queues.begin(); itQueue != proposal.queues.end(); ++itQueue)
|
||||
{
|
||||
uint64 guid = (*itQueue);
|
||||
ObjectGuid guid = (*itQueue);
|
||||
RemoveFromNewQueue(guid);
|
||||
RemoveFromCurrentQueue(guid);
|
||||
}
|
||||
@@ -581,13 +583,13 @@ void LFGQueue::UpdateQueueTimers(time_t currTime)
|
||||
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)
|
||||
{
|
||||
uint64 pguid = itPlayer->first;
|
||||
ObjectGuid pguid = itPlayer->first;
|
||||
LFGMgr::SendLfgQueueStatus(pguid, queueData);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
time_t LFGQueue::GetJoinTime(uint64 guid)
|
||||
time_t LFGQueue::GetJoinTime(ObjectGuid guid)
|
||||
{
|
||||
return QueueDataStore[guid].joinTime;
|
||||
}
|
||||
@@ -600,11 +602,11 @@ std::string LFGQueue::DumpQueueInfo() const
|
||||
|
||||
for (uint8 i = 0; i < 2; ++i)
|
||||
{
|
||||
LfgGuidList const& queue = i ? newToQueueStore : currentQueueStore;
|
||||
for (LfgGuidList::const_iterator it = queue.begin(); it != queue.end(); ++it)
|
||||
GuidList const& queue = i ? newToQueueStore : currentQueueStore;
|
||||
for (GuidList::const_iterator it = queue.begin(); it != queue.end(); ++it)
|
||||
{
|
||||
uint64 guid = *it;
|
||||
if (IS_GROUP_GUID(guid))
|
||||
ObjectGuid guid = *it;
|
||||
if (guid.IsGroup())
|
||||
{
|
||||
groups++;
|
||||
playersInGroup += sLFGMgr->GetPlayerCount(guid);
|
||||
@@ -633,7 +635,7 @@ void LFGQueue::FindBestCompatibleInQueue(LfgQueueDataContainer::iterator itrQueu
|
||||
{
|
||||
TC_LOG_DEBUG("lfg.queue.compatibles.find", "Guid: " UI64FMTD, itrQueue->first);
|
||||
std::ostringstream o;
|
||||
o << itrQueue->first;
|
||||
o << itrQueue->first.GetRawValue();
|
||||
std::string sguid = o.str();
|
||||
|
||||
for (LfgCompatibleContainer::const_iterator itr = CompatibleMapStore.begin(); itr != CompatibleMapStore.end(); ++itr)
|
||||
|
||||
Reference in New Issue
Block a user