Ticket #3427: t3427_improve_replay_error_v1.patch
File t3427_improve_replay_error_v1.patch, 2.5 KB (added by , 9 years ago) |
---|
-
source/main.cpp
436 436 static void RunGameOrAtlas(int argc, const char* argv[]) 437 437 { 438 438 CmdLineArgs args(argc, argv); 439 439 440 440 g_args = args; 441 441 442 442 // We need to initialise libxml2 in the main thread before 443 443 // any thread uses it. So initialise it here before we 444 444 // might run Atlas. 445 445 CXeromyces::Startup(); 446 446 447 447 // run Atlas (if requested via args) 448 bool ran_atlas = ATLAS_RunIfOnCmdLine(args, false);449 448 // Atlas handles the whole init/shutdown/etc sequence by itself; 450 449 // when we get here, it has exited and we're done. 451 if (ran_atlas)450 if (ATLAS_RunIfOnCmdLine(args, false)) 452 451 return; 453 452 454 // run non-visual simulation replay if requested 455 if (args.Has("replay")) 453 const bool isReplay = args.Has("replay"); 454 const bool isVisualReplay = args.Has("replay-visual"); 455 const std::string replayFile = isReplay ? args.Get("replay") : (isVisualReplay ? args.Get("replay-visual") : ""); 456 457 // Ensure the replay file exists 458 if (isReplay || isVisualReplay) 456 459 { 457 std::string replayFile = args.Get("replay");458 460 if (!FileExists(OsPath(replayFile))) 459 461 { 460 462 debug_printf("ERROR: The requested replay file '%s' does not exist!\n", replayFile.c_str()); 461 463 return; 462 464 } 465 if (DirectoryExists(OsPath(replayFile))) 466 { 467 debug_printf("ERROR: The requested replay file '%s' is a directory!\n", replayFile.c_str()); 468 return; 469 } 470 } 471 472 // run non-visual simulation replay if requested 473 if (isReplay) 474 { 463 475 Paths paths(args); 464 476 g_VFS = CreateVfs(20 * MiB); 465 477 g_VFS->Mount(L"cache/", paths.Cache(), VFS_MOUNT_ARCHIVABLE); 466 478 MountMods(paths, GetMods(args, INIT_MODS)); 467 479 468 480 { 469 481 CReplayPlayer replay; 470 482 replay.Load(replayFile); 471 483 replay.Replay(args.Has("serializationtest"), args.Has("ooslog")); 472 484 } 473 485 474 486 g_VFS.reset(); 475 487 476 488 CXeromyces::Terminate(); 477 489 return; 478 490 } 479 491 480 // If visual replay file does not exist, quit before starting the renderer481 if (args.Has("replay-visual"))482 {483 std::string replayFile = args.Get("replay-visual");484 if (!FileExists(OsPath(replayFile)))485 {486 debug_printf("ERROR: The requested replay file '%s' does not exist!\n", replayFile.c_str());487 return;488 }489 }490 491 492 // run in archive-building mode if requested 492 493 if (args.Has("archivebuild")) 493 494 { 494 495 Paths paths(args); 495 496 496 497 OsPath mod(args.Get("archivebuild")); 497 498 OsPath zip; 498 499 if (args.Has("archivebuild-output")) 499 500 zip = args.Get("archivebuild-output"); 500 501 else 501 502 zip = mod.Filename().ChangeExtension(L".zip"); 502 503