move world loaded check and message printing to plugin_enable()

develop
Susan 2021-01-30 15:14:46 +00:00
parent 545fcf6745
commit 8540fd84a4
1 changed files with 19 additions and 13 deletions

@ -100,7 +100,23 @@ string searchAbbreviations(string in)
DFhackCExport command_result plugin_enable(color_ostream &out, bool enable) 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; return CR_OK;
} }
@ -142,22 +158,12 @@ command_result df_seedwatch(color_ostream &out, vector<string>& parameters)
} }
else if(par == "start") else if(par == "start")
{ {
if(Core::getInstance().isWorldLoaded()) plugin_enable(out, true);
{
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") else if(par == "stop")
{ {
running = false; plugin_enable(out, false);
out.print("seedwatch supervision stopped.\n");
} }
else if(par == "clear") else if(par == "clear")
{ {