From b506f0a2403beb862a2ac6eece1540c29156969f Mon Sep 17 00:00:00 2001 From: Susan Date: Sat, 16 Jan 2021 23:01:25 +0000 Subject: [PATCH 1/7] remove misleading comment per https://github.com/DFHack/dfhack/issues/682#issuecomment-138705257, seedwatch supports linux and has done for over a decade. --- plugins/seedwatch.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/plugins/seedwatch.cpp b/plugins/seedwatch.cpp index 5f254a955..bc65bc4ff 100644 --- a/plugins/seedwatch.cpp +++ b/plugins/seedwatch.cpp @@ -1,4 +1,3 @@ -// This does not work with Linux Dwarf Fortress // With thanks to peterix for DFHack and Quietust for information http://www.bay12forums.com/smf/index.php?topic=91166.msg2605147#msg2605147 #include From 7a14bf475ffa020b53bbc67b8fb482068536880d Mon Sep 17 00:00:00 2001 From: Susan Date: Sat, 16 Jan 2021 23:23:05 +0000 Subject: [PATCH 2/7] don't turn off seedwatch on map load fixes #682 --- plugins/seedwatch.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/plugins/seedwatch.cpp b/plugins/seedwatch.cpp index bc65bc4ff..378433957 100644 --- a/plugins/seedwatch.cpp +++ b/plugins/seedwatch.cpp @@ -283,6 +283,9 @@ DFhackCExport command_result plugin_onstatechange(color_ostream &out, state_chan { switch (event) { case SC_MAP_LOADED: + if(running) + out.print("seedwatch supervision started.\n"); + break; case SC_MAP_UNLOADED: if (running) out.printerr("seedwatch deactivated due to game load/unload\n"); From 84b07005d874e6c4c0d9198caf7f62bf623d59cc Mon Sep 17 00:00:00 2001 From: Susan Date: Sat, 16 Jan 2021 23:47:41 +0000 Subject: [PATCH 3/7] tabs to spaces [whoops] --- plugins/seedwatch.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/plugins/seedwatch.cpp b/plugins/seedwatch.cpp index 378433957..3be0bf845 100644 --- a/plugins/seedwatch.cpp +++ b/plugins/seedwatch.cpp @@ -283,9 +283,9 @@ DFhackCExport command_result plugin_onstatechange(color_ostream &out, state_chan { switch (event) { case SC_MAP_LOADED: - if(running) - out.print("seedwatch supervision started.\n"); - break; + if(running) + out.print("seedwatch supervision started.\n"); + break; case SC_MAP_UNLOADED: if (running) out.printerr("seedwatch deactivated due to game load/unload\n"); From b57286c59c2dc26f3b2c869fcf7a56488da76be1 Mon Sep 17 00:00:00 2001 From: Susan Date: Sun, 17 Jan 2021 17:32:31 +0000 Subject: [PATCH 4/7] update changelog --- docs/changelog.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/docs/changelog.txt b/docs/changelog.txt index fdc7c13e7..2e46d7644 100644 --- a/docs/changelog.txt +++ b/docs/changelog.txt @@ -35,6 +35,7 @@ changelog.txt uses a syntax similar to RST, with a few special sequences: ## Fixes - `embark-assistant`: fixed order of factors when calculating min temperature +- `seedwatch`: don't turn off upon map load # 0.47.04-r4 From 98f3142c92e4410b0c9f4e7657f819b5ab5092b4 Mon Sep 17 00:00:00 2001 From: Su Date: Thu, 28 Jan 2021 18:00:34 +0000 Subject: [PATCH 5/7] change deactivation message to be more accurate Co-authored-by: Alan --- plugins/seedwatch.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/seedwatch.cpp b/plugins/seedwatch.cpp index 3be0bf845..83e2e1be9 100644 --- a/plugins/seedwatch.cpp +++ b/plugins/seedwatch.cpp @@ -288,7 +288,7 @@ DFhackCExport command_result plugin_onstatechange(color_ostream &out, state_chan break; case SC_MAP_UNLOADED: if (running) - out.printerr("seedwatch deactivated due to game load/unload\n"); + out.printerr("seedwatch deactivated due to game unload\n"); running = false; break; default: From a3b0cda069cda0f27ac7a1c63c4f879fd8d23dcd Mon Sep 17 00:00:00 2001 From: Susan Date: Fri, 29 Jan 2021 11:26:46 +0000 Subject: [PATCH 6/7] don't enable if no world is loaded --- plugins/seedwatch.cpp | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/plugins/seedwatch.cpp b/plugins/seedwatch.cpp index 3be0bf845..171b2d9a4 100644 --- a/plugins/seedwatch.cpp +++ b/plugins/seedwatch.cpp @@ -142,8 +142,17 @@ command_result df_seedwatch(color_ostream &out, vector& parameters) } else if(par == "start") { - running = true; - out.print("seedwatch supervision started.\n"); + 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 if(par == "stop") { From 8540fd84a4924d132a40dcf7218e5b1cc00be466 Mon Sep 17 00:00:00 2001 From: Susan Date: Sat, 30 Jan 2021 15:14:46 +0000 Subject: [PATCH 7/7] 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") {