Almost match CMemoryCardDriver::InitializeFileInfo

This commit is contained in:
Henrique Gemignani Passos Lima 2022-10-11 20:51:39 +03:00
parent fdd31b8283
commit c41d43ebcb
No known key found for this signature in database
GPG Key ID: E224F951761145F8
2 changed files with 19 additions and 10 deletions

View File

@ -65,9 +65,11 @@ public:
ECardResult WriteFile();
ECardResult CloseFile();
rstl::vector<u8>& SaveBuffer() { return xf4_saveBuffer; }
inline CMemoryStreamOut BeginMemoryOut(uint sz) {
xf4_saveBuffer.resize(sz, '\x00');
return CMemoryStreamOut(xf4_saveBuffer.data(), sz, CMemoryStreamOut::kOS_NotOwned, sz);
return CMemoryStreamOut(xf4_saveBuffer.data(), sz);
}
};
CHECK_SIZEOF(CCardFileInfo, 0x114)

View File

@ -661,7 +661,12 @@ void CMemoryCardDriver::InitializeFileInfo() {
fileInfo.SetComment(rstl::string_l(nameConstant) + nameBuffer);
fileInfo.LockBannerToken(x4_saveBanner, *gpSimplePool);
fileInfo.LockIconToken(x8_saveIcon0, 2, *gpSimplePool);
CMemoryStreamOut w = fileInfo.BeginMemoryOut(3004);
// CMemoryStreamOut w(fileInfo.BeginMemoryOut(3004));
rstl::vector< u8 >& saveBuffer = fileInfo.SaveBuffer();
saveBuffer.resize(3004, '\x00');
CMemoryStreamOut w(saveBuffer.data(), 3004);
SSaveHeader header(0);
for (int i = 0; i < xe4_fileSlots.capacity(); ++i) {
@ -669,12 +674,13 @@ void CMemoryCardDriver::InitializeFileInfo() {
}
header.DoPut(w);
w.Put(x30_systemData.data(), x30_systemData.size());
w.Put(x30_systemData.data(), x30_systemData.capacity());
for (int i = 0; i < xe4_fileSlots.size(); ++i) {
rstl::auto_ptr< SGameFileSlot >& fileSlot = xe4_fileSlots[i];
if (!fileSlot.null()) {
fileSlot->DoPut(w);
for (rstl::reserved_vector< rstl::auto_ptr< SGameFileSlot >, 3 >::iterator it =
xe4_fileSlots.begin();
it != xe4_fileSlots.end(); ++it) {
if (!it->null()) {
(*it)->DoPut(w);
}
}
}
@ -806,10 +812,11 @@ const CGameState::GameFileStateInfo* CMemoryCardDriver::GetGameFileStateInfo(int
};
bool CMemoryCardDriver::GetCardFreeBytes() {
if (CMemoryCardSys::GetNumFreeBytes(x0_cardPort, x18_cardFreeBytes, x1c_cardFreeFiles) != kCR_READY) {
if (CMemoryCardSys::GetNumFreeBytes(x0_cardPort, x18_cardFreeBytes, x1c_cardFreeFiles) !=
kCR_READY) {
NoCardFound();
return false;
}
return true;
}
}