| 826 | } |
| 827 | |
| 828 | DFhackCExport command_result plugin_load_site_data (color_ostream &out) { |
| 829 | cycle_timestamp = 0; |
| 830 | config = World::GetPersistentSiteData(CONFIG_KEY); |
| 831 | |
| 832 | if (!config.isValid()) { |
| 833 | DEBUG(control,out).print("no config found in this save; initializing\n"); |
| 834 | config = World::AddPersistentSiteData(CONFIG_KEY); |
| 835 | config.set_bool(CONFIG_IS_ENABLED, is_enabled); |
| 836 | config.set_bool(CONFIG_PREVENT_BLOCKING, true); |
| 837 | } |
| 838 | |
| 839 | is_enabled = config.get_bool(CONFIG_IS_ENABLED); |
| 840 | suspendmanager_instance->prevent_blocking = config.get_bool(CONFIG_PREVENT_BLOCKING); |
| 841 | DEBUG(control,out).print("loading persisted state: enabled is {} / prevent_blocking is {}\n", |
| 842 | is_enabled ? "true" : "false", |
| 843 | suspendmanager_instance->prevent_blocking ? "true" : "false"); |
| 844 | if(is_enabled) { |
| 845 | DEBUG(control,out).print("registering job event handlers\n"); |
| 846 | EventManager::registerListener(EventManager::EventType::JOB_COMPLETED, *eventhandler_instance); |
| 847 | EventManager::registerListener(EventManager::EventType::JOB_INITIATED, *eventhandler_instance); |
| 848 | do_cycle(out); |
| 849 | } |
| 850 | |
| 851 | return CR_OK; |
| 852 | } |
| 853 | |
| 854 | DFhackCExport command_result plugin_onstatechange(color_ostream &out, state_change_event event) { |
| 855 | if (event == DFHack::SC_WORLD_UNLOADED) { |