[win32] Remove copy of CelestiaCore::runScript, part 2

pull/3/head
Hleb Valoshka 2019-10-19 12:56:39 +03:00
parent d63b65f83e
commit 1ab6b27f3f
1 changed files with 1 additions and 35 deletions

View File

@ -3977,43 +3977,9 @@ LRESULT CALLBACK MainWindowProc(HWND hWnd,
appCore->flash(_("Loading URL"));
appCore->goToUrl(urlString);
}
else if (DetermineFileType(urlString) == Content_CelestiaScript)
{
appCore->runScript(urlString);
}
else
{
ifstream scriptfile(urlString.c_str());
if (!scriptfile.good())
{
appCore->flash(_("Error opening script"));
}
else
{
// TODO: Need to fix memory leak with scripts;
// a refcount is probably required.
CommandParser parser(scriptfile, appCore->scriptMaps());
CommandSequence* script = parser.parse();
if (script == NULL)
{
const vector<string>* errors = parser.getErrors();
const char* errorMsg = "";
if (errors->size() > 0)
{
errorMsg = (*errors)[0].c_str();
appCore->flash(errorMsg);
}
else
{
appCore->flash(_("Error loading script"));
}
}
else
{
appCore->flash(_("Running script"));
appCore->runScript(script);
}
}
appCore->runScript(urlString);
}
}
}