report to the console and stderr when we run inits

develop
myk002 2021-09-22 13:30:10 -07:00 committed by Myk
parent dbe87d4156
commit a7085ea36b
1 changed files with 12 additions and 8 deletions

@ -1400,13 +1400,15 @@ command_result Core::runCommand(color_ostream &con, const std::string &first_, v
bool Core::loadScriptFile(color_ostream &out, string fname, bool silent) bool Core::loadScriptFile(color_ostream &out, string fname, bool silent)
{ {
if(!silent) if(!silent) {
out << "Loading script at " << fname << std::endl; out << "Loading script: " << fname << std::endl;
cerr << "Loading script: " << fname << std::endl;
}
ifstream script(fname.c_str()); ifstream script(fname.c_str());
if ( !script.good() ) if ( !script.good() )
{ {
if(!silent) if(!silent)
out.printerr("Error loading script\n"); out.printerr("Error loading script: %s\n", fname.c_str());
return false; return false;
} }
string command; string command;
@ -1449,7 +1451,7 @@ static void run_dfhack_init(color_ostream &out, Core *core)
if (!count || !Filesystem::isfile("dfhack.init")) if (!count || !Filesystem::isfile("dfhack.init"))
{ {
core->runCommand(out, "gui/no-dfhack-init"); core->runCommand(out, "gui/no-dfhack-init");
core->loadScriptFile(out, "dfhack.init-example", true); core->loadScriptFile(out, "dfhack.init-example", false);
} }
} }
@ -2161,7 +2163,10 @@ size_t loadScriptFiles(Core* core, color_ostream& out, const vector<std::string>
size_t result = 0; size_t result = 0;
for ( size_t a = 0; a < scriptFiles.size(); a++ ) { for ( size_t a = 0; a < scriptFiles.size(); a++ ) {
result++; result++;
core->loadScriptFile(out, folder + "/" + scriptFiles[a], true); std::string path = "";
if (folder != ".")
path = folder + "/";
core->loadScriptFile(out, path + scriptFiles[a], false);
} }
return result; return result;
} }
@ -2228,12 +2233,11 @@ void Core::handleLoadAndUnloadScripts(color_ostream& out, state_change_event eve
{ {
if (!it->save_specific) if (!it->save_specific)
{ {
if (!loadScriptFile(out, it->path, true)) loadScriptFile(out, it->path, false);
out.printerr("Could not load script: %s\n", it->path.c_str());
} }
else if (it->save_specific && isWorldLoaded()) else if (it->save_specific && isWorldLoaded())
{ {
loadScriptFile(out, rawFolder + it->path, true); loadScriptFile(out, rawFolder + it->path, false);
} }
} }
} }