From b1da312932f4815dda5467397975be012a795c14 Mon Sep 17 00:00:00 2001 From: Henrique Gemignani Passos Lima Date: Tue, 11 Oct 2022 20:04:52 +0300 Subject: [PATCH] Add SGameFileSlot/SSaveHeader constructors Former-commit-id: fb0c6815accdea1999697c35c270ebac62c7538e --- include/MetroidPrime/CMemoryCardDriver.hpp | 4 +--- src/MetroidPrime/CMemoryCardDriver.cpp | 11 +++++++---- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/include/MetroidPrime/CMemoryCardDriver.hpp b/include/MetroidPrime/CMemoryCardDriver.hpp index 8543395d..c60e1f6e 100644 --- a/include/MetroidPrime/CMemoryCardDriver.hpp +++ b/include/MetroidPrime/CMemoryCardDriver.hpp @@ -41,9 +41,7 @@ struct SSaveHeader { uint x0_version; bool x4_savePresent[3]; - SSaveHeader(); - // : x0_version(0) {} - + explicit SSaveHeader(int); explicit SSaveHeader(CMemoryInStream& in); void DoPut(CMemoryStreamOut& out) const; diff --git a/src/MetroidPrime/CMemoryCardDriver.cpp b/src/MetroidPrime/CMemoryCardDriver.cpp index 7155eafc..127a1f2c 100644 --- a/src/MetroidPrime/CMemoryCardDriver.cpp +++ b/src/MetroidPrime/CMemoryCardDriver.cpp @@ -662,7 +662,7 @@ void CMemoryCardDriver::InitializeFileInfo() { CMemoryStreamOut w = x198_fileInfo->BeginMemoryOut(3004); - SSaveHeader header; + SSaveHeader header(0); for (int i = 0; i < xe4_fileSlots.capacity(); ++i) { header.x4_savePresent[i] = !xe4_fileSlots[i].null(); } @@ -757,7 +757,7 @@ void CMemoryCardDriver::ExportPersistentOptions() { opts.PutTo(w); } -// SSaveHeader::SSaveHeader(int) +SSaveHeader::SSaveHeader(int i) : x0_version(i) {} SSaveHeader::SSaveHeader(CMemoryInStream& in) { x0_version = in.ReadLong(); @@ -773,9 +773,12 @@ void SSaveHeader::DoPut(CMemoryStreamOut& out) const { } } -SGameFileSlot::SGameFileSlot() {} +SGameFileSlot::SGameFileSlot() : x0_saveBuffer('\x00') { InitializeFromGameState(); } -SGameFileSlot::SGameFileSlot(CMemoryInStream& in) {} +SGameFileSlot::SGameFileSlot(CMemoryInStream& in) : x0_saveBuffer('\x00') { + in.Get(x0_saveBuffer.data(), x0_saveBuffer.capacity()); + x944_fileInfo = gpGameState->LoadGameFileState(x0_saveBuffer.data()); +} void SGameFileSlot::DoPut(CMemoryStreamOut& w) const { w.Put(x0_saveBuffer.data(), x0_saveBuffer.capacity());