Savestates: Fix optional_savestate_state use

This commit is contained in:
Eladash 2023-11-25 19:06:13 +02:00 committed by Elad Ashkenazi
parent c7c2baae03
commit 5dbeb68ed2
2 changed files with 13 additions and 4 deletions

View file

@ -12,12 +12,16 @@ namespace id_manager
template <>
bool serialize<std::shared_ptr<utils::serial>>(utils::serial& ar, std::shared_ptr<utils::serial>& o)
{
if (!o || !ar.is_writing())
if (!o)
{
o.reset();
o = std::make_shared<utils::serial>();
}
if (!ar.is_writing())
{
o->set_reading_state();
}
ar(o->data);
return true;
}