diff --git a/src/game/boe.main.cpp b/src/game/boe.main.cpp index 947413a7..333fe314 100644 --- a/src/game/boe.main.cpp +++ b/src/game/boe.main.cpp @@ -6,6 +6,7 @@ #include #include +#include #include #include #include @@ -231,8 +232,10 @@ static void process_args(int argc, char* argv[]) { preprocess_args(argc, argv); clara::Args args(argc, argv); clara::Parser cli; - std::string record_to, replay, saved_game; + bool record_unique = false; + boost::optional record_to, replay, saved_game; cli |= clara::Opt(record_to, "record")["--record"]("Records a replay of your session to the specified XML file."); + cli |= clara::Opt(record_unique)["--unique"]("When recording, automatically insert a timestamp into the filename to guarantee uniqueness."); cli |= clara::Opt(replay, "replay-file")["--replay"]("Replays a previously-recorded session from the specified XML file."); cli |= clara::Arg(saved_game, "save-file")("Launch and load a saved game file."); bool show_help = false; @@ -245,11 +248,11 @@ static void process_args(int argc, char* argv[]) { cli.writeToStream(std::cout); exit(0); } - if(!record_to.empty() && init_action_log("record", record_to)) return; - if(!replay.empty() && init_action_log("replay", replay)) return; - if(!saved_game.empty()) { - if(!load_party(argv[1], univ)) { - std::cout << "Failed to load save file: " << argv[1] << std::endl; + if(record_to && init_action_log(record_unique || record_to->empty() ? "record-unique" : "record", *record_to)) return; + if(replay && init_action_log("replay", *replay)) return; + if(saved_game) { + if(!load_party(*saved_game, univ)) { + std::cout << "Failed to load save file: " << *saved_game << std::endl; return; } diff --git a/src/tools/replay.cpp b/src/tools/replay.cpp index 6f05a17c..6bd95d06 100644 --- a/src/tools/replay.cpp +++ b/src/tools/replay.cpp @@ -20,7 +20,7 @@ std::string log_file; Element* next_action; bool init_action_log(std::string command, std::string file) { - if (command == "record") { + if(command == "record-unique") { // If a filename is given, use it as a base, but insert a timestamp for uniqueness. if (file.empty()) file = "BoE"; @@ -33,8 +33,11 @@ bool init_action_log(std::string command, std::string file) { auto tm = *std::localtime(&t); std::ostringstream stream; stream << file << std::put_time(&tm, "_%d-%m-%Y_%H-%M-%S") << ".xml"; - log_file = stream.str(); - + file = stream.str(); + command = "record"; + } + if(command == "record") { + log_file = file; try { Element root_element("actions"); log_document.InsertEndChild(root_element);