1
0
forked from 0ad/0ad

Graceful exit in case of trying to replay a directory. Fixes #3427.

Also remove unneeded variable ran_atlas.

This was SVN commit r17501.
This commit is contained in:
elexis 2015-12-18 21:16:08 +00:00
parent abce6cb737
commit 9cf9695d8d

View File

@ -421,22 +421,32 @@ static void RunGameOrAtlas(int argc, const char* argv[])
// might run Atlas.
CXeromyces::Startup();
// run Atlas (if requested via args)
bool ran_atlas = ATLAS_RunIfOnCmdLine(args, false);
// Atlas handles the whole init/shutdown/etc sequence by itself;
// when we get here, it has exited and we're done.
if(ran_atlas)
if (ATLAS_RunIfOnCmdLine(args, false))
return;
// run non-visual simulation replay if requested
if (args.Has("replay"))
const bool isReplay = args.Has("replay");
const bool isVisualReplay = args.Has("replay-visual");
const std::string replayFile = isReplay ? args.Get("replay") : (isVisualReplay ? args.Get("replay-visual") : "");
// Ensure the replay file exists
if (isReplay || isVisualReplay)
{
std::string replayFile = args.Get("replay");
if (!FileExists(OsPath(replayFile)))
{
debug_printf("ERROR: The requested replay file '%s' does not exist!\n", replayFile.c_str());
return;
}
if (DirectoryExists(OsPath(replayFile)))
{
debug_printf("ERROR: The requested replay file '%s' is a directory!\n", replayFile.c_str());
return;
}
}
// run non-visual simulation replay if requested
if (isReplay)
{
Paths paths(args);
g_VFS = CreateVfs(20 * MiB);
g_VFS->Mount(L"cache/", paths.Cache(), VFS_MOUNT_ARCHIVABLE);
@ -454,17 +464,6 @@ static void RunGameOrAtlas(int argc, const char* argv[])
return;
}
// If visual replay file does not exist, quit before starting the renderer
if (args.Has("replay-visual"))
{
std::string replayFile = args.Get("replay-visual");
if (!FileExists(OsPath(replayFile)))
{
debug_printf("ERROR: The requested replay file '%s' does not exist!\n", replayFile.c_str());
return;
}
}
// run in archive-building mode if requested
if (args.Has("archivebuild"))
{