Skip to content

Commit

Permalink
Savestates: Fixup
Browse files Browse the repository at this point in the history
  • Loading branch information
elad335 committed Apr 13, 2024
1 parent 51b56e8 commit 97bdb5c
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 2 deletions.
5 changes: 5 additions & 0 deletions rpcs3/Emu/Cell/Modules/cellSysutilAvc2.cpp
Expand Up @@ -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);
Expand Down
18 changes: 16 additions & 2 deletions rpcs3/util/fixed_typemap.hpp
Expand Up @@ -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;
Expand Down Expand Up @@ -148,6 +149,12 @@ namespace stx
std::launder(static_cast<T*>(ptr))->save(stx::exact_t<utils::serial&>(ar));
}

template <typename T> requires requires (const T&) { T::saveable(true); }
static bool call_saveable(bool is_writing) noexcept
{
return T::saveable(is_writing);
}

template <typename T>
static typeinfo make_typeinfo()
{
Expand All @@ -167,6 +174,11 @@ namespace stx
r.save = &call_save<T>;
}

if constexpr (!!(requires (const T&) { T::saveable(true); }))
{
r.saveable = &call_saveable<T>;
}

r.is_trivial_and_nonsavable = std::is_trivially_default_constructible_v<T> && !r.save;

#ifdef _MSC_VER
Expand Down Expand Up @@ -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);
}
Expand Down

0 comments on commit 97bdb5c

Please sign in to comment.