| 110 | } |
| 111 | |
| 112 | void DFHack::EventManager::unregister(EventType::EventType e, EventHandler handler) { |
| 113 | for ( auto i = handlers[e].find(handler.plugin); i != handlers[e].end(); ) { |
| 114 | if ( (*i).first != handler.plugin ) |
| 115 | break; |
| 116 | EventHandler &handle = (*i).second; |
| 117 | if ( handle != handler ) { |
| 118 | i++; |
| 119 | continue; |
| 120 | } |
| 121 | DEBUG(log).print("unregistering handler {} from plugin {} for event {}\n", |
| 122 | reinterpret_cast<void*>(handler.eventHandler), |
| 123 | handler.plugin ? handler.plugin->getName() : "<null>", |
| 124 | static_cast<int>(e)); |
| 125 | i = handlers[e].erase(i); |
| 126 | if ( e == EventType::TICK ) |
| 127 | removeFromTickQueue(handler); |
| 128 | } |
| 129 | } |
| 130 | |
| 131 | void DFHack::EventManager::unregisterAll(Plugin* plugin) { |
| 132 | DEBUG(log).print("unregistering all handlers for plugin {}\n", |