| 857 | } |
| 858 | |
| 859 | DFhackCExport command_result plugin_enable(color_ostream &out, bool enable) { |
| 860 | if (!Core::getInstance().isMapLoaded() || !World::isFortressMode()) { |
| 861 | out.printerr("Cannot enable {} without a loaded fort.\n", plugin_name); |
| 862 | return CR_FAILURE; |
| 863 | } |
| 864 | |
| 865 | if (enable != is_enabled) { |
| 866 | is_enabled = enable; |
| 867 | DEBUG(control,out).print("{} from the API; persisting\n", |
| 868 | is_enabled ? "enabled" : "disabled"); |
| 869 | config.set_bool(CONFIG_IS_ENABLED, is_enabled); |
| 870 | if (enable) |
| 871 | do_cycle(out); |
| 872 | } else { |
| 873 | DEBUG(control,out).print("{} from the API, but already {} ; no action\n", |
| 874 | is_enabled ? "enabled" : "disabled", |
| 875 | is_enabled ? "enabled" : "disabled"); |
| 876 | } |
| 877 | return CR_OK; |
| 878 | } |
| 879 | |
| 880 | DFhackCExport command_result plugin_shutdown (color_ostream &out) { |
| 881 | DEBUG(control,out).print("shutting down {}\n", plugin_name); |