When cancelling server timers a core will crash as it is removing a timer from the map and increasing the iterator twice by calling erase() function and afterwards increasing it once again when entering a new cycle of loop. One way of solving this issue is to first collect the timers which must be removed and clean them up at the end. You can also add a simple counter which is increased at each end of the loop's cycle and remove the timer directly from the first loop by specifying the position with the counter itself.
Note that
Replace the following function inside questmanager.cpp:
void CQuestManager::CancelServerTimers(DWORD arg)
{
vector<pair<string, DWORD>> ServerTimersToDelete;
for (const auto& kv : m_mapServerTimer) {
if (kv.first.second == arg) {
LPEVENT event = kv.second;
event_cancel(&event);
ServerTimersToDelete.push_back(kv.first);
}
}
// Delete all the required server timers
for (const auto &timer : ServerTimersToDelete)
m_mapServerTimer.erase(timer);
// Clean up
ServerTimersToDelete.clear();
}
Note that
To see the download links,
Log in or register now.
seems to appear after upgrading code to C++11 or higher.Replace the following function inside questmanager.cpp:
void CQuestManager::CancelServerTimers(DWORD arg)
{
vector<pair<string, DWORD>> ServerTimersToDelete;
for (const auto& kv : m_mapServerTimer) {
if (kv.first.second == arg) {
LPEVENT event = kv.second;
event_cancel(&event);
ServerTimersToDelete.push_back(kv.first);
}
}
// Delete all the required server timers
for (const auto &timer : ServerTimersToDelete)
m_mapServerTimer.erase(timer);
// Clean up
ServerTimersToDelete.clear();
}