Almost match CMemoryCardDriver::BuildNewFileSlot

This commit is contained in:
Henrique Gemignani Passos Lima 2022-10-11 19:08:45 +03:00
parent 9f4fc78c16
commit cdfda89fa6
No known key found for this signature in database
GPG Key ID: E224F951761145F8
2 changed files with 27 additions and 5 deletions

View File

@ -20,6 +20,8 @@ public:
CGameState();
CGameState(CInputStream& in, int saveIdx);
void ReadSystemOptions(CInputStream& in);
rstl::rc_ptr< CPlayerState >& PlayerState();
CAssetId CurrentWorldAssetId();
void WriteBackupBuf();
@ -30,6 +32,8 @@ public:
uint& SaveIdx() { return x20c_saveIdx; }
u64& CardSerial() { return x210_cardSerial; }
rstl::vector< uchar >& BackupBuf() { return x218_backupBuf; }
u32 GetFileIdx() const { return x20c_saveIdx; }
void SetFileIdx(u32 idx) { x20c_saveIdx = idx; }
void SetCardSerial(u64 serial) { x210_cardSerial = serial; }
u64 GetCardSerial() const { return x210_cardSerial; }

View File

@ -706,11 +706,27 @@ void CMemoryCardDriver::ReadFinished() {
}
}
void CMemoryCardDriver::EraseFileSlot(int saveIdx) {
xe4_fileSlots[saveIdx] = nullptr;
}
void CMemoryCardDriver::EraseFileSlot(int saveIdx) { xe4_fileSlots[saveIdx] = nullptr; }
void CMemoryCardDriver::BuildNewFileSlot(int) {}
void CMemoryCardDriver::BuildNewFileSlot(int saveIdx) {
bool fusionBackup = gpGameState->SystemOptions().GetHasFusion();
gpGameState->SetFileIdx(saveIdx);
rstl::auto_ptr< SGameFileSlot >& slot = xe4_fileSlots[saveIdx];
if (slot.null())
slot = new SGameFileSlot();
slot->LoadGameState(saveIdx);
{
CMemoryInStream r(x30_systemData.data(), x30_systemData.capacity());
gpGameState->ReadSystemOptions(r);
}
ImportPersistentOptions();
gpGameState->SetCardSerial(x28_cardSerial);
gpGameState->SystemOptions().SetHasFusion(fusionBackup);
}
void CMemoryCardDriver::BuildExistingFileSlot(int) {}
@ -738,7 +754,9 @@ SGameFileSlot::SGameFileSlot() {}
SGameFileSlot::SGameFileSlot(CMemoryInStream& in) {}
void SGameFileSlot::DoPut(CMemoryStreamOut& w) const { w.Put(x0_saveBuffer.data(), x0_saveBuffer.capacity()); }
void SGameFileSlot::DoPut(CMemoryStreamOut& w) const {
w.Put(x0_saveBuffer.data(), x0_saveBuffer.capacity());
}
void SGameFileSlot::InitializeFromGameState() {}