MCPcopy Create free account
hub / github.com/DFHack/dfhack / command_result plugin_enable

Function command_result plugin_enable

plugins/work-now.cpp:45–67  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

43}
44
45DFhackCExport command_result plugin_enable(color_ostream &out, bool enable) {
46 if (!Core::getInstance().isMapLoaded() || !World::isFortressMode()) {
47 out.printerr("Cannot enable {} without a loaded fort.\n", plugin_name);
48 return CR_FAILURE;
49 }
50
51 if (enable != is_enabled) {
52 is_enabled = enable;
53 DEBUG(log,out).print("{} from the API; persisting\n",
54 is_enabled ? "enabled" : "disabled");
55 config.set_bool(CONFIG_IS_ENABLED, is_enabled);
56 if (enable)
57 EventManager::registerListener(EventManager::EventType::JOB_COMPLETED, handler);
58 else
59 cleanup();
60 } else {
61 DEBUG(log,out).print("{} from the API, but already {} ; no action\n",
62 is_enabled ? "enabled" : "disabled",
63 is_enabled ? "enabled" : "disabled");
64 }
65
66 return CR_OK;
67}
68
69DFhackCExport command_result plugin_shutdown ( color_ostream &out ) {
70 cleanup();

Callers

nothing calls this directly

Calls 2

cleanupFunction · 0.70
printMethod · 0.45

Tested by

no test coverage detected