Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions plugins/timestream.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,10 @@ static void reset_ephemeral_state() {
season_tick_throttled = false;
}

static void do_disable() {
EventManager::unregisterAll(plugin_self);
}

DFhackCExport command_result plugin_enable(color_ostream &out, bool enable) {
if (!Core::getInstance().isMapLoaded() || !World::isFortressMode()) {
out.printerr("Cannot enable %s without a loaded fort.\n", plugin_name);
Expand All @@ -170,7 +174,7 @@ DFhackCExport command_result plugin_enable(color_ostream &out, bool enable) {
EventManager::registerListener(EventManager::EventType::UNIT_NEW_ACTIVE, new_unit_handler);
do_cycle(out);
} else {
EventManager::unregisterAll(plugin_self);
do_disable();
}
} else {
DEBUG(control,out).print("%s from the API, but already %s; no action\n",
Expand Down Expand Up @@ -222,7 +226,7 @@ DFhackCExport command_result plugin_onstatechange(color_ostream &out, state_chan
if (is_enabled) {
DEBUG(control,out).print("world unloaded; disabling %s\n",
plugin_name);
plugin_enable(out, false);
do_disable();
}
}
return CR_OK;
Expand Down