| 58 | } |
| 59 | |
| 60 | DFhackCExport command_result plugin_enable(color_ostream &out, bool enable) { |
| 61 | if (!Core::getInstance().isMapLoaded() || !World::isFortressMode()) { |
| 62 | out.printerr("Cannot enable {} without a loaded fort.\n", plugin_name); |
| 63 | return CR_FAILURE; |
| 64 | } |
| 65 | |
| 66 | if (enable != is_enabled) { |
| 67 | is_enabled = enable; |
| 68 | DEBUG(control,out).print("{} from the API; persisting\n", |
| 69 | is_enabled ? "enabled" : "disabled"); |
| 70 | config.set_bool(CONFIG_IS_ENABLED, is_enabled); |
| 71 | if (enable) |
| 72 | do_cycle(out); |
| 73 | } else { |
| 74 | DEBUG(control,out).print("{} from the API, but already {}; no action\n", |
| 75 | is_enabled ? "enabled" : "disabled", |
| 76 | is_enabled ? "enabled" : "disabled"); |
| 77 | } |
| 78 | return CR_OK; |
| 79 | } |
| 80 | |
| 81 | DFhackCExport command_result plugin_shutdown (color_ostream &out) { |
| 82 | DEBUG(control,out).print("shutting down {}\n", plugin_name); |