Fixed script loading improperly checking for errors.

Also closed the file for good measure.  I couldn't find any documentation that said that ~ifstream() did this.
develop
Clayton Hughes 2012-03-12 00:33:59 -07:00
parent d7f7437ca1
commit 4cb8995a05
1 changed files with 12 additions and 9 deletions

@ -500,12 +500,8 @@ static void loadScriptFile(Core *core, PluginManager *plug_mgr, string fname)
{
core->con << "Loading script at " << fname << std::endl;
ifstream script(fname);
if (script.bad())
if (script.good())
{
core->con.printerr("Error loading script\n");
return;
}
int tmp = 0;
string command;
while (getline(script, command))
@ -514,6 +510,13 @@ static void loadScriptFile(Core *core, PluginManager *plug_mgr, string fname)
runInteractiveCommand(core, plug_mgr, tmp, command);
}
}
else
{
core->con.printerr("Error loading script\n");
}
script.close();
}
// A thread function... for the interactive console.
void fIOthread(void * iodata)