This commit is contained in:
digant 2024-12-27 23:53:46 +01:00
parent 32d8dfc7fe
commit 673182f608
11 changed files with 33 additions and 24 deletions

View file

@ -596,7 +596,7 @@ void fmt_class_string<std::source_location>::format(std::string& out, u64 arg)
}
}
func = func.substr(0, index);
func = func.substr(0, index) + "()";
break;
}

View file

@ -479,10 +479,6 @@ public:
gem_config_data(utils::serial& ar)
{
save(ar);
if (ar.is_writing())
return;
load_configs();
}

View file

@ -186,6 +186,10 @@ struct main_ppu_module : public ppu_module<T>
u32 elf_entry{};
u32 seg0_code_end{};
std::vector<u32> applied_patches;
// Disable inherited savestate ordering
void save(utils::serial&) = delete;
static constexpr double savestate_init_pos = double{};
};
// Aux

View file

@ -186,3 +186,6 @@ lv2_socket& lv2_socket::operator=(thread_state s) noexcept
return *this;
}
lv2_socket::~lv2_socket() noexcept
{
}

View file

@ -64,7 +64,7 @@ public:
lv2_socket(utils::serial&, lv2_socket_type type);
static std::function<void(void*)> load(utils::serial& ar);
void save(utils::serial&, bool save_only_this_class = false);
~lv2_socket() noexcept = default;
virtual ~lv2_socket() noexcept;
lv2_socket& operator=(thread_state s) noexcept;
std::unique_lock<shared_mutex> lock();

View file

@ -57,6 +57,11 @@ void lv2_socket_native::save(utils::serial& ar)
ar(is_socket_connected());
}
lv2_socket_native::~lv2_socket_native() noexcept
{
lv2_socket_native::close();
}
s32 lv2_socket_native::create_socket()
{
ensure(family == SYS_NET_AF_INET);

View file

@ -34,6 +34,7 @@ public:
lv2_socket_native(lv2_socket_family family, lv2_socket_type type, lv2_ip_protocol protocol);
lv2_socket_native(utils::serial& ar, lv2_socket_type type);
~lv2_socket_native() noexcept override;
void save(utils::serial& ar);
s32 create_socket();

View file

@ -1749,8 +1749,7 @@ namespace vm
if (is_memory_compatible_for_copy_from_executable_optimization(addr, shm.first))
{
// Revert changes
ar.data.resize(ar.data.size() - (sizeof(u32) * 2 + sizeof(memory_page)));
ar.seek_end();
ar.trunc(sizeof(u32) * 2 + sizeof(memory_page));
vm_log.success("Removed memory block matching the memory of the executable from savestate. (addr=0x%x, size=0x%x)", addr, shm.first);
continue;
}

View file

@ -42,7 +42,7 @@ static std::array<serial_ver_t, 27> s_serial_versions;
return ::s_serial_versions[identifier].current_version;\
}
SERIALIZATION_VER(global_version, 0, 18) // For stuff not listed here
SERIALIZATION_VER(global_version, 0, 19) // For stuff not listed here
SERIALIZATION_VER(ppu, 1, 1, 2/*PPU sleep order*/, 3/*PPU FNID and module*/)
SERIALIZATION_VER(spu, 2, 1)
SERIALIZATION_VER(lv2_sync, 3, 1)
@ -393,7 +393,7 @@ namespace stx
if ((saved ^ tag) & data_mask)
{
ensure(!ar.is_writing());
fmt::throw_exception("serial_breathe_and_tag(%u): %s, object: '%s', next-object: '%s', expected/tag: 0x%x != 0x%x,", s_tls_call_count, ar, s_tls_object_name, name, tag, saved);
fmt::throw_exception("serial_breathe_and_tag(%u): %s\nobject: '%s', next-object: '%s', expected/tag: 0x%x != 0x%x,", s_tls_call_count, ar, s_tls_object_name, name, tag, saved);
}
s_tls_object_name = name;

View file

@ -108,10 +108,10 @@ public:
{
if (m_is_writing) return;
const u32 offset1 = ::offset32(first) + sizeof(first);
const u32 offset1 = ::offset32(first) + sizeof(T);
const u32 offset2 = ::offset32(second);
AUDIT(offset2 >= offset1);
AUDIT(::offset32(first) <= ::offset32(second));
if (offset2 > offset1)
{
@ -459,10 +459,16 @@ public:
m_file_handler.reset();
}
usz seek_end(usz backwards = 0)
usz seek_end()
{
ensure(data.size() + data_offset >= backwards);
pos = data.size() + data_offset - backwards;
pos = data.size() + data_offset;
return pos;
}
usz trunc(usz count)
{
data.resize(data.size() - count);
seek_end();
return pos;
}

View file

@ -451,23 +451,18 @@ namespace stx
}
}
// Converts to unique (single) ptr if reference is 1, otherwise returns null. Nullifies self.
// Converts to unique (single) ptr if reference is 1. Nullifies self on success.
template <typename U> requires PtrSame<T, U>
explicit operator single_ptr<U>() && noexcept
single_ptr<U> try_convert_to_single_ptr() noexcept
{
const auto o = d();
if (m_ptr && !--o->refs)
if (const auto o = m_ptr ? d() : nullptr; o && o->refs == 1u)
{
// Convert last reference to single_ptr instance.
o->refs.release(1);
single_ptr<T> r;
single_ptr<U> r;
r.m_ptr = static_cast<decltype(r.m_ptr)>(std::exchange(m_ptr, nullptr));
return r;
}
// Otherwise, both pointers are gone. Didn't seem right to do it in the constructor.
m_ptr = nullptr;
return {};
}