System: Check save state version when loading

Fixes #34.
pull/211/head
Connor McLaughlin 5 years ago
parent 959a555274
commit 49c7767ed4

@ -1,4 +1,5 @@
#pragma once
#include "pse/types.h"
#include "types.h"
constexpr u32 SAVE_STATE_VERSION = 1;
static constexpr u32 SAVE_STATE_MAGIC = 0x43435544;
static constexpr u32 SAVE_STATE_VERSION = 1;

@ -16,6 +16,7 @@
#include "mdec.h"
#include "memory_card.h"
#include "pad.h"
#include "save_state_version.h"
#include "sio.h"
#include "spu.h"
#include "timers.h"
@ -271,6 +272,20 @@ bool System::CreateGPU(GPURenderer renderer)
bool System::DoState(StateWrapper& sw)
{
u32 magic = SAVE_STATE_MAGIC;
u32 version = SAVE_STATE_VERSION;
sw.Do(&magic);
if (magic != SAVE_STATE_MAGIC)
return false;
sw.Do(&version);
if (version != SAVE_STATE_VERSION)
{
m_host_interface->ReportFormattedError("Save state is incompatible: expecting version %u but state is version %u.",
SAVE_STATE_VERSION, version);
return false;
}
if (!sw.DoMarker("System"))
return false;

Loading…
Cancel
Save