Core/Dungeon Finder: Fix bad use of iterator that made LFG inconsistent and sometimes crash
Closes issue 4009 --HG-- branch : trunk
This commit is contained in:
@@ -468,32 +468,24 @@ void LFGMgr::Update(uint32 diff)
|
|||||||
void LFGMgr::AddGuidToNewQueue(uint64 guid)
|
void LFGMgr::AddGuidToNewQueue(uint64 guid)
|
||||||
{
|
{
|
||||||
// Consistency check
|
// Consistency check
|
||||||
LfgGuidList::const_iterator it;
|
LfgGuidList::iterator it = std::find(m_newToQueue.begin(), m_newToQueue.end(), guid);
|
||||||
for (it = m_newToQueue.begin(); it != m_newToQueue.end(); ++it)
|
|
||||||
{
|
if (it != m_newToQueue.end())
|
||||||
if (*it == guid)
|
|
||||||
{
|
{
|
||||||
sLog.outError("LFGMgr::AddGuidToNewQueue: [" UI64FMTD "] being added to queue and it was already added. ignoring", guid);
|
sLog.outError("LFGMgr::AddGuidToNewQueue: [" UI64FMTD "] being added to queue and it was already added. ignoring", guid);
|
||||||
break;
|
return;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
if (it == m_newToQueue.end())
|
it = std::find(m_currentQueue.begin(), m_currentQueue.end(), guid);
|
||||||
{
|
if (it != m_currentQueue.end())
|
||||||
LfgGuidList::iterator itRemove;
|
|
||||||
for (LfgGuidList::iterator it = m_currentQueue.begin(); it != m_currentQueue.end() && (*it) != guid;)
|
|
||||||
{
|
|
||||||
itRemove = it++;
|
|
||||||
if (*itRemove == guid)
|
|
||||||
{
|
{
|
||||||
sLog.outError("LFGMgr::AddGuidToNewQueue: [" UI64FMTD "] being added to queue and already in current queue (removing to readd)", guid);
|
sLog.outError("LFGMgr::AddGuidToNewQueue: [" UI64FMTD "] being added to queue and already in current queue (removing to readd)", guid);
|
||||||
m_currentQueue.erase(itRemove);
|
m_currentQueue.erase(it);
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Add to queue
|
// Add to queue
|
||||||
m_newToQueue.push_back(guid);
|
m_newToQueue.push_back(guid);
|
||||||
sLog.outError("DEBUG:LFGMgr::AddGuidToNewQueue: [" UI64FMTD "] added to m_newToQueue (size: %u)", guid, m_newToQueue.size());
|
sLog.outError("DEBUG:LFGMgr::AddGuidToNewQueue: [" UI64FMTD "] added to m_newToQueue (size: %u)", guid, m_newToQueue.size());
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -726,8 +718,8 @@ void LFGMgr::Leave(Player* plr, Group* grp /* = NULL*/)
|
|||||||
|
|
||||||
// Remove from Proposals
|
// Remove from Proposals
|
||||||
bool proposalFound = false;
|
bool proposalFound = false;
|
||||||
LfgProposalMap::iterator it;
|
LfgProposalMap::iterator it = m_Proposals.begin();
|
||||||
for (it = m_Proposals.begin(); it != m_Proposals.end() && !proposalFound; ++it)
|
while (it != m_Proposals.end() && !proposalFound)
|
||||||
{
|
{
|
||||||
// Mark the player/leader of group who left as didn't accept the proposal
|
// Mark the player/leader of group who left as didn't accept the proposal
|
||||||
for (LfgProposalPlayerMap::iterator itPlayer = it->second->players.begin(); itPlayer != it->second->players.end(); ++itPlayer)
|
for (LfgProposalPlayerMap::iterator itPlayer = it->second->players.begin(); itPlayer != it->second->players.end(); ++itPlayer)
|
||||||
@@ -738,6 +730,8 @@ void LFGMgr::Leave(Player* plr, Group* grp /* = NULL*/)
|
|||||||
proposalFound = true;
|
proposalFound = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (!proposalFound)
|
||||||
|
++it;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Remove from queue - if proposal is found, RemoveProposal will call RemoveFromQueue
|
// Remove from queue - if proposal is found, RemoveProposal will call RemoveFromQueue
|
||||||
|
|||||||
Reference in New Issue
Block a user