mirror of
https://github.com/RPCS3/rpcs3.git
synced 2024-11-22 02:32:36 +01:00
IdManager.h: Savestate fix part 2
This commit is contained in:
parent
b2e969eb8f
commit
d335d356ca
@ -48,10 +48,13 @@ namespace id_manager
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
concept IdmCompatible = requires () { T::id_base, T::id_step, T::id_count; };
|
||||
concept IdmCompatible = requires () { +T::id_base, +T::id_step, +T::id_count; };
|
||||
|
||||
template <typename T>
|
||||
concept IdmSavable = IdmCompatible<T> && T::savestate_init_pos != 0 && (requires () { std::declval<T>().save(std::declval<stx::exact_t<utils::serial&>>()); });
|
||||
concept IdmBaseCompatible = (std::is_final_v<T> ? IdmCompatible<T> : !!(requires () { +T::id_step, +T::id_count; }));
|
||||
|
||||
template <typename T>
|
||||
concept IdmSavable = IdmBaseCompatible<T> && T::savestate_init_pos != 0 && (requires () { std::declval<T>().save(std::declval<stx::exact_t<utils::serial&>>()); });
|
||||
|
||||
// Last allocated ID for constructors
|
||||
extern thread_local u32 g_id;
|
||||
@ -103,7 +106,7 @@ namespace id_manager
|
||||
template <typename T>
|
||||
struct id_traits_load_func<T, std::void_t<decltype(&T::load)>>
|
||||
{
|
||||
static constexpr std::shared_ptr<void>(*load)(utils::serial&) = &T::load;
|
||||
static constexpr std::shared_ptr<void>(*load)(utils::serial&) = [](utils::serial& ar) -> std::shared_ptr<void> { return T::load(stx::exact_t<utils::serial&>(ar)); };
|
||||
};
|
||||
|
||||
template <typename T, typename = void>
|
||||
@ -172,7 +175,7 @@ namespace id_manager
|
||||
{
|
||||
typeinfo info{};
|
||||
|
||||
using C = std::conditional_t<IdmSavable<T>, T, dummy_construct>;
|
||||
using C = std::conditional_t<IdmCompatible<T> && IdmSavable<T>, T, dummy_construct>;
|
||||
using Type = std::conditional_t<IdmCompatible<T>, T, dummy_construct>;
|
||||
|
||||
if constexpr (std::is_same_v<C, T>)
|
||||
@ -248,6 +251,8 @@ namespace id_manager
|
||||
template <typename T>
|
||||
struct id_map
|
||||
{
|
||||
static_assert(IdmBaseCompatible<T>, "Please specify IDM compatible type.");
|
||||
|
||||
std::vector<std::pair<id_key, std::shared_ptr<void>>> vec{}, private_copy{};
|
||||
shared_mutex mutex{}; // TODO: Use this instead of global mutex
|
||||
|
||||
|
@ -117,13 +117,6 @@ namespace stx
|
||||
*std::launder(static_cast<T*>(ptr)) = state;
|
||||
}
|
||||
|
||||
#ifdef _MSC_VER
|
||||
template <typename T>
|
||||
static void call_save(void*, utils::serial&) noexcept
|
||||
{
|
||||
}
|
||||
#endif
|
||||
|
||||
template <typename T> requires requires (T& a) { a.save(std::declval<stx::exact_t<utils::serial&>>()); }
|
||||
static void call_save(void* ptr, utils::serial& ar) noexcept
|
||||
{
|
||||
@ -144,10 +137,7 @@ namespace stx
|
||||
r.stop = &call_stop<T>;
|
||||
}
|
||||
|
||||
// TODO: Unconnement and remove call_save overload when MSVC implements it
|
||||
#ifndef _MSC_VER
|
||||
if constexpr (!!(requires (T& a) { a.save(std::declval<stx::exact_t<utils::serial&>>()); }))
|
||||
#endif
|
||||
{
|
||||
r.save = &call_save<T>;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user