diff --git a/library/Core.cpp b/library/Core.cpp index b298b9550..4712be0a7 100644 --- a/library/Core.cpp +++ b/library/Core.cpp @@ -70,7 +70,7 @@ using df::global::init; // FIXME: A lot of code in one file, all doing different things... there's something fishy about it. -static void loadScriptFile(Core *core, PluginManager *plug_mgr, string fname); +static void loadScriptFile(Core *core, PluginManager *plug_mgr, string fname, bool silent); static void runInteractiveCommand(Core *core, PluginManager *plug_mgr, int &clueless_counter, const string &command); static bool parseKeySpec(std::string keyspec, int *psym, int *pmod); @@ -492,7 +492,7 @@ static void runInteractiveCommand(Core *core, PluginManager *plug_mgr, int &clue { if(parts.size() == 1) { - loadScriptFile(core, plug_mgr, parts[0]); + loadScriptFile(core, plug_mgr, parts[0], false); } else { @@ -512,9 +512,10 @@ static void runInteractiveCommand(Core *core, PluginManager *plug_mgr, int &clue } } -static void loadScriptFile(Core *core, PluginManager *plug_mgr, string fname) +static void loadScriptFile(Core *core, PluginManager *plug_mgr, string fname, bool silent) { - core->getConsole() << "Loading script at " << fname << std::endl; + if(!silent) + core->getConsole() << "Loading script at " << fname << std::endl; ifstream script(fname); if (script.good()) { @@ -528,7 +529,8 @@ static void loadScriptFile(Core *core, PluginManager *plug_mgr, string fname) } else { - core->getConsole().printerr("Error loading script\n"); + if(!silent) + core->getConsole().printerr("Error loading script\n"); } script.close(); @@ -551,7 +553,7 @@ void fIOthread(void * iodata) return; } - loadScriptFile(core, plug_mgr, "dfhack.init"); + loadScriptFile(core, plug_mgr, "dfhack.init", true); con.print("DFHack is ready. Have a nice day!\n" "Type in '?' or 'help' for general help, 'ls' to see all commands.\n"); diff --git a/library/Process-linux.cpp b/library/Process-linux.cpp index ddc62daf8..fe8647845 100644 --- a/library/Process-linux.cpp +++ b/library/Process-linux.cpp @@ -25,6 +25,7 @@ distribution. #include "Internal.h" #include #include +#include #include #include diff --git a/plugins/autolabor.cpp b/plugins/autolabor.cpp index 733f08066..6511f72db 100644 --- a/plugins/autolabor.cpp +++ b/plugins/autolabor.cpp @@ -397,17 +397,14 @@ struct dwarf_info DFhackCExport command_result plugin_init ( color_ostream &out, std::vector &commands) { - // initialize labor infos table from default table - - labor_infos = new struct labor_info[ARRAY_COUNT(default_labor_infos)]; - for (int i = 0; i < ARRAY_COUNT(default_labor_infos); i++) { - labor_infos[i] = default_labor_infos[i]; - } - - assert(ARRAY_COUNT(labor_infos) > ENUM_LAST_ITEM(unit_labor)); - - // Fill the command list with your commands. - commands.clear(); + // initialize labor infos table from default table + if(ARRAY_COUNT(default_labor_infos) != ENUM_LAST_ITEM(unit_labor) + 1) + return CR_FAILURE; + labor_infos = new struct labor_info[ARRAY_COUNT(default_labor_infos)]; + for (int i = 0; i < ARRAY_COUNT(default_labor_infos); i++) { + labor_infos[i] = default_labor_infos[i]; + } + // Fill the command list with your commands. commands.push_back(PluginCommand( "autolabor", "Automatically manage dwarf labors.", autolabor, false, /* true means that the command can't be used from non-interactive user interface */