diff --git a/game/src/questmanager.cpp b/game/src/questmanager.cpp index 8af4b32..fc23ed9 100644 --- a/game/src/questmanager.cpp +++ b/game/src/questmanager.cpp @@ -1724,14 +1724,20 @@ namespace quest void CQuestManager::CancelServerTimers(DWORD arg) { - itertype(m_mapServerTimer) it = m_mapServerTimer.begin(); - for ( ; it != m_mapServerTimer.end(); ++it) { - if (it->first.second == arg) { - LPEVENT event = it->second; - event_cancel(&event); - m_mapServerTimer.erase(it); - } - } + vector> timersToDelete; + + // Find server timers that need deleting + for (auto& kv: m_mapServerTimer) { + if (kv.first.second == arg) { + LPEVENT event = kv.second; + event_cancel(&event); + timersToDelete.push_back(kv.first); + } + } + + // Delete all the required server timers + for (const auto &timer: timersToDelete) + m_mapServerTimer.erase(timer); } void CQuestManager::SetServerTimerArg(DWORD dwArg)