From 97bdb5c9bb3855c46f2da26429f8d029e1743d94 Mon Sep 17 00:00:00 2001 From: Eladash <18193363+elad335@users.noreply.github.com> Date: Sat, 13 Apr 2024 19:03:39 +0300 Subject: [PATCH] Savestates: Fixup --- rpcs3/Emu/Cell/Modules/cellSysutilAvc2.cpp | 5 +++++ rpcs3/util/fixed_typemap.hpp | 18 ++++++++++++++++-- 2 files changed, 21 insertions(+), 2 deletions(-) diff --git a/rpcs3/Emu/Cell/Modules/cellSysutilAvc2.cpp b/rpcs3/Emu/Cell/Modules/cellSysutilAvc2.cpp index 46c908080e54..d8d38e9545c0 100644 --- a/rpcs3/Emu/Cell/Modules/cellSysutilAvc2.cpp +++ b/rpcs3/Emu/Cell/Modules/cellSysutilAvc2.cpp @@ -77,6 +77,11 @@ struct avc2_settings u8 video_stream_sharing = 0; u32 total_video_bitrate = 0; + static bool saveable(bool is_writing) noexcept + { + return GET_SERIALIZATION_VERSION(cellSysutil) != 0; + } + avc2_settings(utils::serial& ar) noexcept { [[maybe_unused]] const s32 version = GET_SERIALIZATION_VERSION(cellSysutil); diff --git a/rpcs3/util/fixed_typemap.hpp b/rpcs3/util/fixed_typemap.hpp index 18ccf8488040..5ca200e49d77 100644 --- a/rpcs3/util/fixed_typemap.hpp +++ b/rpcs3/util/fixed_typemap.hpp @@ -73,6 +73,7 @@ namespace stx bool(*create)(uchar* ptr, manual_typemap&, utils::serial*, std::string_view) noexcept = nullptr; void(*thread_op)(void* ptr, thread_state) noexcept = nullptr; void(*save)(void* ptr, utils::serial&) noexcept = nullptr; + bool(*saveable)(bool) noexcept = nullptr; void(*destroy)(void* ptr) noexcept = nullptr; bool is_trivial_and_nonsavable = false; std::string_view name; @@ -148,6 +149,12 @@ namespace stx std::launder(static_cast(ptr))->save(stx::exact_t(ar)); } + template requires requires (const T&) { T::saveable(true); } + static bool call_saveable(bool is_writing) noexcept + { + return T::saveable(is_writing); + } + template static typeinfo make_typeinfo() { @@ -167,6 +174,11 @@ namespace stx r.save = &call_save; } + if constexpr (!!(requires (const T&) { T::saveable(true); })) + { + r.saveable = &call_saveable; + } + r.is_trivial_and_nonsavable = std::is_trivially_default_constructible_v && !r.save; #ifdef _MSC_VER @@ -284,13 +296,15 @@ namespace stx continue; } - if (type.create(data, *this, ar, type.name)) + const bool saveable = type.saveable(false); + + if (type.create(data, *this, saveable ? ar : nullptr, type.name)) { *m_order++ = data; *m_info++ = &type; m_init[id] = true; - if (ar && type.save) + if (ar && saveable && type.save) { serial_breathe_and_tag(*ar, type.name, false); }