From 798e88224ade9d24f4a2b7f3b5d1f6332ffe2ddc Mon Sep 17 00:00:00 2001 From: Wildenhaus Date: Sat, 15 Dec 2018 15:40:38 -0500 Subject: [PATCH] Ordinal offset calculation for games with many files --- src/xenia/vfs/devices/stfs_container_device.cc | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/xenia/vfs/devices/stfs_container_device.cc b/src/xenia/vfs/devices/stfs_container_device.cc index a04215a3e..b93173319 100644 --- a/src/xenia/vfs/devices/stfs_container_device.cc +++ b/src/xenia/vfs/devices/stfs_container_device.cc @@ -288,10 +288,16 @@ StfsContainerDevice::Error StfsContainerDevice::ReadSVOD() { StfsContainerDevice::Error StfsContainerDevice::ReadEntrySVOD( 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 size_t entry_address, entry_file; - BlockToOffsetSVOD(block, &entry_address, &entry_file); - entry_address += ordinal * 0x04; + BlockToOffsetSVOD(block + block_offset, &entry_address, &entry_file); + entry_address += true_ordinal_offset; // Read block's descriptor auto data = mmap_.at(entry_file)->data() + entry_address;