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

Function command_result plugin_enable

plugins/suspendmanager.cpp:794–819  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

792}
793
794DFhackCExport command_result plugin_enable(color_ostream &out, bool enable) {
795 if (!Core::getInstance().isMapLoaded() || !World::isFortressMode()) {
796 out.printerr("Cannot enable {} without a loaded fort.\n", plugin_name);
797 return CR_FAILURE;
798 }
799
800 if (enable != is_enabled) {
801 is_enabled = enable;
802 DEBUG(control,out).print("{} from the API; persisting\n",
803 is_enabled ? "enabled" : "disabled");
804 config.set_bool(CONFIG_IS_ENABLED, is_enabled);
805 if (enable) {
806 EventManager::registerListener(EventManager::EventType::JOB_COMPLETED, *eventhandler_instance);
807 EventManager::registerListener(EventManager::EventType::JOB_INITIATED, *eventhandler_instance);
808 do_cycle(out);
809 } else {
810 EventManager::unregisterAll(plugin_self);
811 }
812
813 } else {
814 DEBUG(control,out).print("{} from the API, but already {}; no action\n",
815 is_enabled ? "enabled" : "disabled",
816 is_enabled ? "enabled" : "disabled");
817 }
818 return CR_OK;
819}
820
821DFhackCExport command_result plugin_shutdown (color_ostream &out) {
822 DEBUG(control,out).print("shutting down {}\n", plugin_name);

Callers

nothing calls this directly

Calls 2

do_cycleFunction · 0.70
printMethod · 0.45

Tested by

no test coverage detected