From 5dbeb68ed2f271198ced87a16041720d081c4e05 Mon Sep 17 00:00:00 2001 From: Eladash <18193363+elad335@users.noreply.github.com> Date: Sat, 25 Nov 2023 19:06:13 +0200 Subject: [PATCH] Savestates: Fix optional_savestate_state use --- rpcs3/Emu/Cell/PPUThread.cpp | 9 +++++++-- rpcs3/Emu/IdManager.cpp | 8 ++++++-- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/rpcs3/Emu/Cell/PPUThread.cpp b/rpcs3/Emu/Cell/PPUThread.cpp index b44c281175..67085ea103 100644 --- a/rpcs3/Emu/Cell/PPUThread.cpp +++ b/rpcs3/Emu/Cell/PPUThread.cpp @@ -2364,9 +2364,14 @@ void ppu_thread::serialize_common(utils::serial& ar) ar(optional_savestate_state, vr); - if (optional_savestate_state->data.empty()) + if (!ar.is_writing()) { - optional_savestate_state->clear(); + if (optional_savestate_state->data.empty()) + { + optional_savestate_state->clear(); + } + + optional_savestate_state->set_reading_state(); } } diff --git a/rpcs3/Emu/IdManager.cpp b/rpcs3/Emu/IdManager.cpp index 4b8549109e..8db94b2e51 100644 --- a/rpcs3/Emu/IdManager.cpp +++ b/rpcs3/Emu/IdManager.cpp @@ -12,12 +12,16 @@ namespace id_manager template <> bool serialize>(utils::serial& ar, std::shared_ptr& o) { - if (!o || !ar.is_writing()) + if (!o) { - o.reset(); o = std::make_shared(); } + if (!ar.is_writing()) + { + o->set_reading_state(); + } + ar(o->data); return true; }