Ordinal offset calculation for games with many files

This commit is contained in:
Wildenhaus 2018-12-15 15:40:38 -05:00
parent 151a955c6a
commit 798e88224a
1 changed files with 8 additions and 2 deletions

View File

@ -288,10 +288,16 @@ StfsContainerDevice::Error StfsContainerDevice::ReadSVOD() {
StfsContainerDevice::Error StfsContainerDevice::ReadEntrySVOD( StfsContainerDevice::Error StfsContainerDevice::ReadEntrySVOD(
uint32_t block, uint32_t ordinal, StfsContainerEntry* parent) { uint32_t block, uint32_t ordinal, StfsContainerEntry* parent) {
// For games with a large amount of files, the ordinal offset can overrun
// the current block and potentially hit a hash block.
size_t ordinal_offset = ordinal * 0x4;
size_t block_offset = ordinal_offset / 0x800;
size_t true_ordinal_offset = ordinal_offset % 0x800;
// Calculate the file & address of the block // Calculate the file & address of the block
size_t entry_address, entry_file; size_t entry_address, entry_file;
BlockToOffsetSVOD(block, &entry_address, &entry_file); BlockToOffsetSVOD(block + block_offset, &entry_address, &entry_file);
entry_address += ordinal * 0x04; entry_address += true_ordinal_offset;
// Read block's descriptor // Read block's descriptor
auto data = mmap_.at(entry_file)->data() + entry_address; auto data = mmap_.at(entry_file)->data() + entry_address;