diff --git a/rpcs3/Emu/Cell/lv2/sys_fs.cpp b/rpcs3/Emu/Cell/lv2/sys_fs.cpp index 4e1817493b..88f2553a7c 100644 --- a/rpcs3/Emu/Cell/lv2/sys_fs.cpp +++ b/rpcs3/Emu/Cell/lv2/sys_fs.cpp @@ -447,8 +447,11 @@ lv2_file::lv2_file(utils::serial& ar) if (ar.operator bool()) // see lv2_file::save in_mem { - std::vector buf = ar; const fs::stat_t stat = ar; + + std::vector buf(stat.size); + ar(std::span(buf.data(), buf.size())); + file = fs::make_stream>(std::move(buf), stat); } @@ -514,6 +517,10 @@ void lv2_file::save(utils::serial& ar) sys_fs.error("Saving \'%s\' LV2 file descriptor in memory! (exists=%s, type=%s, flags=0x%x, size=0x%x)", name.data(), fs::is_file(real_path), type, flags, stats.size); + const usz patch_stats_pos = ar.seek_end(); + + ar(stats); + const usz old_end = ar.pad_from_end(stats.size); if (usz read_size = file.read_at(0, &ar.data[old_end], stats.size); read_size != stats.size) @@ -522,9 +529,8 @@ void lv2_file::save(utils::serial& ar) sys_fs.error("Read less than expected! (new-size=0x%x)", read_size); stats.size = read_size; ar.data.resize(old_end + stats.size); + write_to_ptr(&ar.data[patch_stats_pos], stats); } - - ar(stats); } ar(file.pos()); diff --git a/rpcs3/Emu/Cell/lv2/sys_fs.h b/rpcs3/Emu/Cell/lv2/sys_fs.h index 24cee886b8..b838ce8228 100644 --- a/rpcs3/Emu/Cell/lv2/sys_fs.h +++ b/rpcs3/Emu/Cell/lv2/sys_fs.h @@ -199,7 +199,7 @@ struct CellFsMountInfo; // Forward Declaration struct lv2_fs_mount_info_map { public: - SAVESTATE_INIT_POS(49); + SAVESTATE_INIT_POS(40); lv2_fs_mount_info_map(); lv2_fs_mount_info_map(const lv2_fs_mount_info_map&) = delete; @@ -228,7 +228,7 @@ struct lv2_fs_object static constexpr u32 id_step = 1; static constexpr u32 id_count = 255 - id_base; static constexpr bool id_lowest = true; - SAVESTATE_INIT_POS(40); + SAVESTATE_INIT_POS(49); // File Name (max 1055) const std::array name; diff --git a/rpcs3/Emu/VFS.cpp b/rpcs3/Emu/VFS.cpp index fa94323198..bdcb11d265 100644 --- a/rpcs3/Emu/VFS.cpp +++ b/rpcs3/Emu/VFS.cpp @@ -31,8 +31,6 @@ struct vfs_manager // VFS root vfs_directory root{}; - - SAVESTATE_INIT_POS(48); }; bool vfs::mount(std::string_view vpath, std::string_view path, bool is_dir) diff --git a/rpcs3/Emu/savestate_utils.cpp b/rpcs3/Emu/savestate_utils.cpp index d2ac671cc3..7934892ccf 100644 --- a/rpcs3/Emu/savestate_utils.cpp +++ b/rpcs3/Emu/savestate_utils.cpp @@ -35,7 +35,7 @@ static std::array s_serial_versions; return ::s_serial_versions[identifier].current_version;\ } -SERIALIZATION_VER(global_version, 0, 14) // For stuff not listed here +SERIALIZATION_VER(global_version, 0, 15) // For stuff not listed here SERIALIZATION_VER(ppu, 1, 1) SERIALIZATION_VER(spu, 2, 1) SERIALIZATION_VER(lv2_sync, 3, 1)