mirror of
https://github.com/RPCS3/rpcs3.git
synced 2025-07-07 23:41:26 +12:00
Savestates/System.cpp: Realized fix for suspend mode (#12883)
This commit is contained in:
parent
61a371b106
commit
c8620070b9
1 changed files with 30 additions and 28 deletions
|
@ -666,34 +666,7 @@ game_boot_result Emulator::BootGame(const std::string& path, const std::string&
|
||||||
{
|
{
|
||||||
m_path = path;
|
m_path = path;
|
||||||
|
|
||||||
auto error = Load(title_id, add_only);
|
return Load(title_id, add_only);
|
||||||
|
|
||||||
if (g_cfg.savestate.suspend_emu && error == game_boot_result::no_errors)
|
|
||||||
{
|
|
||||||
for (std::string old_path : std::initializer_list<std::string>{m_ar ? path : "", m_title_id.empty() ? "" : get_savestate_path(m_title_id, path)})
|
|
||||||
{
|
|
||||||
if (old_path.empty())
|
|
||||||
{
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
std::string new_path = old_path.substr(0, old_path.find_last_not_of(fs::delim) + 1);
|
|
||||||
const usz insert_pos = new_path.find_last_of(fs::delim) + 1;
|
|
||||||
const auto prefix = "used_"sv;
|
|
||||||
|
|
||||||
if (new_path.compare(insert_pos, prefix.size(), prefix) != 0)
|
|
||||||
{
|
|
||||||
new_path.insert(insert_pos, prefix);
|
|
||||||
|
|
||||||
if (fs::rename(old_path, new_path, true))
|
|
||||||
{
|
|
||||||
sys_log.notice("Savestate has been moved to path='%s'", new_path);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return error;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
game_boot_result result = game_boot_result::nothing_to_boot;
|
game_boot_result result = game_boot_result::nothing_to_boot;
|
||||||
|
@ -945,6 +918,8 @@ game_boot_result Emulator::Load(const std::string& title_id, bool add_only, bool
|
||||||
m_cat.clear();
|
m_cat.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
m_path_old = m_path;
|
||||||
|
|
||||||
if (argv[0].starts_with("/dev_hdd0"sv))
|
if (argv[0].starts_with("/dev_hdd0"sv))
|
||||||
{
|
{
|
||||||
m_path = rpcs3::utils::get_hdd0_dir();
|
m_path = rpcs3::utils::get_hdd0_dir();
|
||||||
|
@ -1984,6 +1959,32 @@ void Emulator::FixGuestTime()
|
||||||
|
|
||||||
CallFromMainThread([this]
|
CallFromMainThread([this]
|
||||||
{
|
{
|
||||||
|
// Mark a known savestate location and the one we try to boot (in case we boot a moved/copied savestate)
|
||||||
|
if (g_cfg.savestate.suspend_emu)
|
||||||
|
{
|
||||||
|
for (std::string old_path : std::initializer_list<std::string>{m_ar ? m_path_old : "", m_title_id.empty() ? "" : get_savestate_path(m_title_id, m_path_old)})
|
||||||
|
{
|
||||||
|
if (old_path.empty())
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
std::string new_path = old_path.substr(0, old_path.find_last_not_of(fs::delim) + 1);
|
||||||
|
const usz insert_pos = new_path.find_last_of(fs::delim) + 1;
|
||||||
|
const auto prefix = "used_"sv;
|
||||||
|
|
||||||
|
if (new_path.compare(insert_pos, prefix.size(), prefix) != 0)
|
||||||
|
{
|
||||||
|
new_path.insert(insert_pos, prefix);
|
||||||
|
|
||||||
|
if (fs::rename(old_path, new_path, true))
|
||||||
|
{
|
||||||
|
sys_log.success("Savestate has been moved (hidden) to path='%s'", new_path);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
m_ar.reset();
|
m_ar.reset();
|
||||||
|
|
||||||
g_tls_log_prefix = []()
|
g_tls_log_prefix = []()
|
||||||
|
@ -1997,6 +1998,7 @@ void Emulator::FixGuestTime()
|
||||||
initialize_timebased_time(0);
|
initialize_timebased_time(0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Emulator::FinalizeRunRequest()
|
void Emulator::FinalizeRunRequest()
|
||||||
{
|
{
|
||||||
auto on_select = [](u32, spu_thread& spu)
|
auto on_select = [](u32, spu_thread& spu)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue