EventManager: Fixed a problem with deregistering event frequencies.

develop
expwnent 2013-01-03 19:07:05 -05:00
parent 910e398a7b
commit 9e74ae58f2
1 changed files with 11 additions and 1 deletions

@ -120,13 +120,23 @@ void DFHack::EventManager::unregisterAll(Plugin* plugin) {
int32_t freq = (*b).second;
eventFrequency[a][freq]--;
if ( eventFrequency[a][freq] < 0 ) {
Core::getInstance().getConsole().print("%s, line %d: Error: incorrect frequency on deregister.\n", __FILE__, __LINE__);
Core::getInstance().getConsole().print("%s, line %d: Error: incorrect frequency on deregister: %d, %d.\n", __FILE__, __LINE__, a, freq);
eventFrequency[a].erase(eventFrequency[a].find(freq));
} else if ( eventFrequency[a][freq] == 0 ) {
eventFrequency[a].erase(eventFrequency[a].find(freq));
}
}
}
//now delete the frequencies from the thing
for ( size_t a = 0; a < EventType::EVENT_MAX; a++ ) {
for ( auto b = pluginFrequencies[a].begin(); b != pluginFrequencies[a].end(); b++ ) {
if ( (*b).first != plugin )
continue;
pluginFrequencies[a].erase(b);
a--;
break;
}
}
return;
}