Sio: Only eject memory cards when loading state if changed

[SAVEVERSION+] Regression from #6741.
This commit is contained in:
Connor McLaughlin 2022-11-19 14:58:25 +10:00 committed by refractionpcsx2
parent 0e73bf1e6d
commit c883e9d792
2 changed files with 27 additions and 2 deletions

View File

@ -33,7 +33,7 @@ enum class FreezeAction
// [SAVEVERSION+]
// This informs the auto updater that the users savestates will be invalidated.
static const u32 g_SaveVersion = (0x9A31 << 16) | 0x0000;
static const u32 g_SaveVersion = (0x9A32 << 16) | 0x0000;
// the freezing data between submodules and core

View File

@ -917,9 +917,34 @@ void SaveStateBase::sio2Freeze()
Freeze(sio2);
// CRCs for memory cards.
// If the memory card hasn't changed when loading state, we can safely skip ejecting it.
u64 mcdCrcs[SIO::PORTS][SIO::SLOTS];
if (IsSaving())
{
for (u32 port = 0; port < SIO::PORTS; port++)
{
for (u32 slot = 0; slot < SIO::SLOTS; slot++)
mcdCrcs[port][slot] = mcds[port][slot].GetChecksum();
}
}
Freeze(mcdCrcs);
if (IsLoading())
{
bool ejected = false;
for (u32 port = 0; port < SIO::PORTS && !ejected; port++)
{
for (u32 slot = 0; slot < SIO::SLOTS; slot++)
{
if (mcdCrcs[port][slot] != mcds[port][slot].GetChecksum())
{
AutoEject::SetAll();
ejected = true;
break;
}
}
}
// Restore fifoIn
fifoIn.clear();