From 96d31cf64e171bf530864bb484496d5399c0f4c3 Mon Sep 17 00:00:00 2001 From: Eladash Date: Sun, 1 Oct 2023 14:41:17 +0300 Subject: [PATCH] IdManager.h: Savestate fix --- rpcs3/Emu/Cell/lv2/sys_net.cpp | 2 +- rpcs3/Emu/Cell/lv2/sys_net/lv2_socket.h | 2 +- rpcs3/Emu/IdManager.h | 9 ++++++--- 3 files changed, 8 insertions(+), 5 deletions(-) diff --git a/rpcs3/Emu/Cell/lv2/sys_net.cpp b/rpcs3/Emu/Cell/lv2/sys_net.cpp index 026ab67559..383d2f8e35 100644 --- a/rpcs3/Emu/Cell/lv2/sys_net.cpp +++ b/rpcs3/Emu/Cell/lv2/sys_net.cpp @@ -266,7 +266,7 @@ lv2_socket::lv2_socket(utils::serial& ar, lv2_socket_type _type) ar(last_bound_addr); } -std::shared_ptr lv2_socket::load(utils::serial& ar) +std::shared_ptr lv2_socket::load(utils::serial& ar) { const lv2_socket_type type{ar}; diff --git a/rpcs3/Emu/Cell/lv2/sys_net/lv2_socket.h b/rpcs3/Emu/Cell/lv2/sys_net/lv2_socket.h index 68afbe26c8..7bf5985dd8 100644 --- a/rpcs3/Emu/Cell/lv2/sys_net/lv2_socket.h +++ b/rpcs3/Emu/Cell/lv2/sys_net/lv2_socket.h @@ -60,7 +60,7 @@ public: lv2_socket(lv2_socket_family family, lv2_socket_type type, lv2_ip_protocol protocol); lv2_socket(utils::serial&) {} lv2_socket(utils::serial&, lv2_socket_type type); - static std::shared_ptr load(utils::serial& ar); + static std::shared_ptr load(utils::serial& ar); void save(utils::serial&, bool save_only_this_class = false); virtual ~lv2_socket() = default; diff --git a/rpcs3/Emu/IdManager.h b/rpcs3/Emu/IdManager.h index 02c809ffb5..363b555c13 100644 --- a/rpcs3/Emu/IdManager.h +++ b/rpcs3/Emu/IdManager.h @@ -50,6 +50,9 @@ namespace id_manager template concept IdmCompatible = requires () { T::id_base, T::id_step, T::id_count; }; + template + concept IdmSavable = IdmCompatible && T::savestate_init_pos != 0 && (requires () { std::declval().save(std::declval>()); }); + // Last allocated ID for constructors extern thread_local u32 g_id; @@ -169,7 +172,7 @@ namespace id_manager { typeinfo info{}; - using C = std::conditional_t && std::is_constructible_v>, T, dummy_construct>; + using C = std::conditional_t, T, dummy_construct>; using Type = std::conditional_t, T, dummy_construct>; if constexpr (std::is_same_v) @@ -258,7 +261,7 @@ namespace id_manager static constexpr double savestate_init_pos_original = T::savestate_init_pos; static constexpr double savestate_init_pos = std::bit_cast(std::bit_cast(savestate_init_pos_original) - 1); - id_map(utils::serial& ar) noexcept requires (savestate_init_pos_original != 0 && std::is_constructible_v>) + id_map(utils::serial& ar) noexcept requires IdmSavable { vec.resize(T::id_count); @@ -298,7 +301,7 @@ namespace id_manager } } - void save(utils::serial& ar) requires (savestate_init_pos_original != 0 && std::is_constructible_v>) + void save(utils::serial& ar) requires IdmSavable { u32 obj_count = 0; usz obj_count_offs = ar.data.size();