VMManager: Reload save state ELF in internals

We should serialize this in the state at some point.
This commit is contained in:
Connor McLaughlin 2022-09-18 14:46:16 +10:00 committed by refractionpcsx2
parent ffa014f910
commit 99fbe4e9ff
2 changed files with 20 additions and 7 deletions

View File

@ -215,6 +215,10 @@ SaveStateBase& SaveStateBase::FreezeBios()
SaveStateBase& SaveStateBase::FreezeInternals()
{
#ifdef PCSX2_CORE
const u32 previousCRC = ElfCRC;
#endif
// Print this until the MTVU problem in gifPathFreeze is taken care of (rama)
if (THREAD_VU1) Console.Warning("MTVU speedhack is enabled, saved states may not be stable");
@ -235,8 +239,24 @@ SaveStateBase& SaveStateBase::FreezeInternals()
StringUtil::Strlcpy(localDiscSerial, DiscSerial.c_str(), sizeof(localDiscSerial));
Freeze(localDiscSerial);
if (IsLoading())
{
DiscSerial = localDiscSerial;
#ifdef PCSX2_CORE
if (ElfCRC != previousCRC)
{
// HACK: LastELF isn't in the save state... Load it before we go too far into restoring state.
// When we next bump save states, we should include it. We need this for achievements, because
// we want to load and activate achievements before restoring any of their tracked state.
if (const std::string& elf_override = VMManager::Internal::GetElfOverride(); !elf_override.empty())
cdvdReloadElfInfo(fmt::format("host:{}", elf_override));
else
cdvdReloadElfInfo();
}
#endif
}
// Third Block - Cycle Timers and Events
// -------------------------------------
FreezeTag( "Cycles" );

View File

@ -1152,13 +1152,6 @@ bool VMManager::DoLoadState(const char* filename)
{
Host::OnSaveStateLoading(filename);
SaveState_UnzipFromDisk(filename);
// HACK: LastELF isn't in the save state...
if (!s_elf_override.empty())
cdvdReloadElfInfo(fmt::format("host:{}", s_elf_override));
else
cdvdReloadElfInfo();
UpdateRunningGame(false, false);
Host::OnSaveStateLoaded(filename, true);
return true;