Append the timestamp to the save/replay file name.
Also fixes the unit tests to be able to find the replay since hard-coding the expected replay name will no longer work. Fixes #4730
This commit is contained in:
parent
8ba16c972a
commit
c394353d48
2 changed files with 8 additions and 2 deletions
|
@ -571,9 +571,9 @@ game_launcher::unit_test_result game_launcher::single_unit_test()
|
|||
}
|
||||
|
||||
savegame::replay_savegame save(state_, compression::NONE);
|
||||
save.save_game_automatic(false, "unit_test_replay"); //false means don't check for overwrite
|
||||
save.save_game_automatic(false, "unit_test_replay");
|
||||
|
||||
load_data_.reset(new savegame::load_game_metadata{ savegame::save_index_class::default_saves_dir(), "unit_test_replay" , "", true, true, false });
|
||||
load_data_.reset(new savegame::load_game_metadata{ savegame::save_index_class::default_saves_dir(), save.filename() , "", true, true, false });
|
||||
|
||||
if (!load_game()) {
|
||||
std::cerr << "Failed to load the replay!" << std::endl;
|
||||
|
|
|
@ -47,6 +47,7 @@
|
|||
#include "video.hpp"
|
||||
|
||||
#include <algorithm>
|
||||
#include <iomanip>
|
||||
|
||||
static lg::log_domain log_engine("engine");
|
||||
#define LOG_SAVE LOG_STREAM(info, log_engine)
|
||||
|
@ -451,6 +452,11 @@ bool savegame::save_game(const std::string& filename)
|
|||
if (filename_.empty())
|
||||
filename_ = filename;
|
||||
|
||||
time_t t = std::time(nullptr);
|
||||
tm tm = *std::localtime(&t);
|
||||
auto time = std::put_time(&tm, "%Y%m%d-%H%M%S");
|
||||
filename_ = (formatter() << filename_ << '_' << time).str();
|
||||
|
||||
before_save();
|
||||
|
||||
write_game_to_disk(filename_);
|
||||
|
|
Loading…
Add table
Reference in a new issue