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;
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))
{
if (!command.empty())
runInteractiveCommand(core, plug_mgr, tmp, command);
}
}
int tmp = 0;
string command;
while (getline(script, command))
else
{
if (!command.empty())
runInteractiveCommand(core, plug_mgr, tmp, command);
core->con.printerr("Error loading script\n");
}
script.close();
}
// A thread function... for the interactive console.