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,19 +500,22 @@ static void loadScriptFile(Core *core, PluginManager *plug_mgr, string fname)
{ {
core->con << "Loading script at " << fname << std::endl; core->con << "Loading script at " << fname << std::endl;
ifstream script(fname); ifstream script(fname);
if (script.bad()) if (script.good())
{ {
core->con.printerr("Error loading script\n"); int tmp = 0;
return; string command;
while (getline(script, command))
{
if (!command.empty())
runInteractiveCommand(core, plug_mgr, tmp, command);
}
} }
else
int tmp = 0;
string command;
while (getline(script, command))
{ {
if (!command.empty()) core->con.printerr("Error loading script\n");
runInteractiveCommand(core, plug_mgr, tmp, command);
} }
script.close();
} }
// A thread function... for the interactive console. // A thread function... for the interactive console.