Almost match CMemoryCardDriver::BuildNewFileSlot

Former-commit-id: cdfda89fa6
This commit is contained in:
Henrique Gemignani Passos Lima 2022-10-11 19:08:45 +03:00
parent 4f2a8704db
commit b079ad7432
2 changed files with 27 additions and 5 deletions

View File

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

View File

@ -706,11 +706,27 @@ void CMemoryCardDriver::ReadFinished() {
} }
} }
void CMemoryCardDriver::EraseFileSlot(int saveIdx) { void CMemoryCardDriver::EraseFileSlot(int saveIdx) { xe4_fileSlots[saveIdx] = nullptr; }
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) {} void CMemoryCardDriver::BuildExistingFileSlot(int) {}
@ -738,7 +754,9 @@ SGameFileSlot::SGameFileSlot() {}
SGameFileSlot::SGameFileSlot(CMemoryInStream& in) {} 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() {} void SGameFileSlot::InitializeFromGameState() {}