From 56619b20cfd55ca969ecde36af3dd7b12d77b76d Mon Sep 17 00:00:00 2001 From: Eladash Date: Fri, 15 Jul 2022 20:32:09 +0300 Subject: [PATCH] Savestates: savestate reload fix --- rpcs3/Emu/System.cpp | 2 +- rpcs3/Emu/savestate_utils.cpp | 20 ++++++++++++++------ 2 files changed, 15 insertions(+), 7 deletions(-) diff --git a/rpcs3/Emu/System.cpp b/rpcs3/Emu/System.cpp index 481b5f6e05..e4e7b50823 100644 --- a/rpcs3/Emu/System.cpp +++ b/rpcs3/Emu/System.cpp @@ -79,7 +79,7 @@ extern void ppu_unload_prx(const lv2_prx&); extern std::shared_ptr ppu_load_prx(const ppu_prx_object&, const std::string&, s64 = 0, utils::serial* = nullptr); extern std::pair, CellError> ppu_load_overlay(const ppu_exec_object&, const std::string& path, s64 = 0, utils::serial* = nullptr); extern bool ppu_load_rel_exec(const ppu_rel_object&); -extern bool is_savestate_version_compatible(const std::vector>& data, bool log); +extern bool is_savestate_version_compatible(const std::vector>& data, bool is_boot_check); extern std::vector> read_used_savestate_versions(); fs::file g_tty; diff --git a/rpcs3/Emu/savestate_utils.cpp b/rpcs3/Emu/savestate_utils.cpp index 806c874770..1c1d00d5bb 100644 --- a/rpcs3/Emu/savestate_utils.cpp +++ b/rpcs3/Emu/savestate_utils.cpp @@ -108,7 +108,7 @@ std::vector> get_savestate_versioning_data(const fs::file& f return ar; } -bool is_savestate_version_compatible(const std::vector>& data, bool log) +bool is_savestate_version_compatible(const std::vector>& data, bool is_boot_check) { if (data.empty()) { @@ -121,20 +121,28 @@ bool is_savestate_version_compatible(const std::vector>& dat { if (identifier >= s_serial_versions.size()) { - (log ? sys_log.error : sys_log.trace)("Savestate version identider is unknown! (category=%u, version=%u)", identifier, version); + (is_boot_check ? sys_log.error : sys_log.trace)("Savestate version identider is unknown! (category=%u, version=%u)", identifier, version); ok = false; // Log all mismatches } else if (!s_serial_versions[identifier].compatible_versions.count(version)) { - (log ? sys_log.error : sys_log.trace)("Savestate version is not supported. (category=%u, version=%u)", identifier, version); + (is_boot_check ? sys_log.error : sys_log.trace)("Savestate version is not supported. (category=%u, version=%u)", identifier, version); ok = false; } - else + else if (is_boot_check) { s_serial_versions[identifier].current_version = version; } } + if (!ok && is_boot_check) + { + for (auto [identifier, _] : data) + { + s_serial_versions[identifier].current_version = 0; + } + } + return ok; } @@ -170,7 +178,7 @@ bool boot_last_savestate() const std::string save_dir = fs::get_cache_dir() + "/savestates/"; std::string savestate_path; - u64 mtime = umax; + s64 mtime = smin; for (auto&& entry : fs::dir(save_dir)) { @@ -180,7 +188,7 @@ bool boot_last_savestate() } // Find the latest savestate file compatible with the game (TODO: Check app version and anything more) - if (entry.name.find(Emu.GetTitleID()) != umax && mtime < entry.mtime) + if (entry.name.find(Emu.GetTitleID()) != umax && mtime <= entry.mtime) { if (std::string path = save_dir + entry.name; is_savestate_compatible(fs::file(path))) {