Fixed quest server timers cancellation

This commit is contained in:
Exynox 2022-12-24 20:46:00 +02:00
parent f56d5028da
commit a04cd735de
1 changed files with 14 additions and 8 deletions

View File

@ -1724,14 +1724,20 @@ namespace quest
void CQuestManager::CancelServerTimers(DWORD arg) void CQuestManager::CancelServerTimers(DWORD arg)
{ {
itertype(m_mapServerTimer) it = m_mapServerTimer.begin(); vector<pair<string, DWORD>> timersToDelete;
for ( ; it != m_mapServerTimer.end(); ++it) {
if (it->first.second == arg) { // Find server timers that need deleting
LPEVENT event = it->second; for (auto& kv: m_mapServerTimer) {
if (kv.first.second == arg) {
LPEVENT event = kv.second;
event_cancel(&event); event_cancel(&event);
m_mapServerTimer.erase(it); 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) void CQuestManager::SetServerTimerArg(DWORD dwArg)