From f5995474b141cc9d1da6ff2e14cd7ff97803eb86 Mon Sep 17 00:00:00 2001 From: "Dr. Chat" Date: Wed, 28 Sep 2016 18:33:25 -0500 Subject: [PATCH] Write the title ID to savestates - and disallow loading savestates from a different title for the moment. --- src/xenia/emulator.cc | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/xenia/emulator.cc b/src/xenia/emulator.cc index 2c5969de4..77c08217b 100644 --- a/src/xenia/emulator.cc +++ b/src/xenia/emulator.cc @@ -338,7 +338,7 @@ bool Emulator::SaveToFile(const std::wstring& path) { filesystem::CreateFile(path); auto map = MappedMemory::Open(path, MappedMemory::Mode::kReadWrite, 0, - 1024ull * 1024ull * 1024ull * 4ull); + 1024ull * 1024ull * 1024ull * 2ull); if (!map) { return false; } @@ -346,6 +346,7 @@ bool Emulator::SaveToFile(const std::wstring& path) { // Save the emulator state to a file ByteStream stream(map->data(), map->size()); stream.Write('XSAV'); + stream.Write(title_id_); // It's important we don't hold the global lock here! XThreads need to step // forward (possibly through guarded regions) without worry! @@ -379,6 +380,13 @@ bool Emulator::RestoreFromFile(const std::wstring& path) { return false; } + auto title_id = stream.Read(); + if (title_id != title_id_) { + // Swapping between titles is unsupported at the moment. + assert_always(); + return false; + } + if (!processor_->Restore(&stream)) { XELOGE("Could not restore processor!"); return false;