From 8540fd84a4924d132a40dcf7218e5b1cc00be466 Mon Sep 17 00:00:00 2001 From: Susan Date: Sat, 30 Jan 2021 15:14:46 +0000 Subject: [PATCH] move world loaded check and message printing to plugin_enable() --- plugins/seedwatch.cpp | 32 +++++++++++++++++++------------- 1 file changed, 19 insertions(+), 13 deletions(-) diff --git a/plugins/seedwatch.cpp b/plugins/seedwatch.cpp index 36863ec8d..f233cb27f 100644 --- a/plugins/seedwatch.cpp +++ b/plugins/seedwatch.cpp @@ -100,7 +100,23 @@ string searchAbbreviations(string in) DFhackCExport command_result plugin_enable(color_ostream &out, bool enable) { - running = enable; + if(enable == true) + { + if(Core::getInstance().isWorldLoaded()) + { + running = true; + out.print("seedwatch supervision started.\n"); + } else { + out.printerr( + "This plugin needs a fortress to be loaded and will deactivate automatically otherwise.\n" + "Activate with 'seedwatch start' after you load the game.\n" + ); + } + } else { + running = false; + out.print("seedwatch supervision stopped.\n"); + } + return CR_OK; } @@ -142,22 +158,12 @@ command_result df_seedwatch(color_ostream &out, vector& parameters) } else if(par == "start") { - if(Core::getInstance().isWorldLoaded()) - { - running = true; - out.print("seedwatch supervision started.\n"); - } else { - out.printerr( - "This plugin needs a fortress to be loaded and will deactivate automatically otherwise.\n" - "Activate with 'seedwatch start' after you load the game.\n" - ); - } + plugin_enable(out, true); } else if(par == "stop") { - running = false; - out.print("seedwatch supervision stopped.\n"); + plugin_enable(out, false); } else if(par == "clear") {