From dccd89b796d1adb66234fb8b4b88f346573c5a73 Mon Sep 17 00:00:00 2001 From: Vitor Kiguchi Date: Wed, 5 Apr 2023 15:48:03 -0300 Subject: [PATCH] savestates: various changes The header doesn't need to be serialized. GetSaveStatePath may be static. Remove unused includes. Name the CryptoPP stringsource. --- src/core/savestate.cpp | 16 ++++------------ src/core/savestate.h | 2 -- 2 files changed, 4 insertions(+), 14 deletions(-) diff --git a/src/core/savestate.cpp b/src/core/savestate.cpp index b96f20ed1..efbbe3eb4 100644 --- a/src/core/savestate.cpp +++ b/src/core/savestate.cpp @@ -3,18 +3,15 @@ // Refer to the license.txt file included. #include -#include #include #include "common/archives.h" #include "common/logging/log.h" #include "common/scm_rev.h" #include "common/zstd_compression.h" -#include "core/cheats/cheats.h" #include "core/core.h" #include "core/movie.h" #include "core/savestate.h" #include "network/network.h" -#include "video_core/video_core.h" namespace Core { @@ -25,19 +22,14 @@ struct CSTHeader { std::array revision; /// Git hash of the revision this savestate was created with u64_le time; /// The time when this save state was created - std::array reserved; /// Make heading 256 bytes so it has consistent size - - template - void serialize(Archive& ar, const unsigned int) { - ar& boost::serialization::binary_object(this, sizeof(CSTHeader)); - } + std::array reserved{}; /// Make heading 256 bytes so it has consistent size }; static_assert(sizeof(CSTHeader) == 256, "CSTHeader should be 256 bytes"); #pragma pack(pop) constexpr std::array header_magic_bytes{{'C', 'S', 'T', 0x1B}}; -std::string GetSaveStatePath(u64 program_id, u32 slot) { +static std::string GetSaveStatePath(u64 program_id, u32 slot) { const u64 movie_id = Movie::GetInstance().GetCurrentMovieID(); if (movie_id) { return fmt::format("{}{:016X}.movie{:016X}.{:02d}.cst", @@ -131,8 +123,8 @@ void System::SaveState(u32 slot) const { header.filetype = header_magic_bytes; header.program_id = title_id; std::string rev_bytes; - CryptoPP::StringSource(Common::g_scm_rev, true, - new CryptoPP::HexDecoder(new CryptoPP::StringSink(rev_bytes))); + CryptoPP::StringSource ss(Common::g_scm_rev, true, + new CryptoPP::HexDecoder(new CryptoPP::StringSink(rev_bytes))); std::memcpy(header.revision.data(), rev_bytes.data(), sizeof(header.revision)); header.time = std::chrono::duration_cast( std::chrono::system_clock::now().time_since_epoch()) diff --git a/src/core/savestate.h b/src/core/savestate.h index f67bee22f..2a1d1db52 100644 --- a/src/core/savestate.h +++ b/src/core/savestate.h @@ -9,8 +9,6 @@ namespace Core { -struct CSTHeader; - struct SaveStateInfo { u32 slot; u64 time;