From 4f05e156210b12c15f6ffca4cc2cb14b66cb6037 Mon Sep 17 00:00:00 2001 From: Michael Becker Date: Mon, 21 Mar 2022 15:31:58 -0400 Subject: [PATCH] kind of hacky but all the test files work now --- .../DataFormats/FileSystem/CPK/CPKDataFormat.cs | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/Plugins/UniversalEditor.Plugins.CRI/DataFormats/FileSystem/CPK/CPKDataFormat.cs b/Plugins/UniversalEditor.Plugins.CRI/DataFormats/FileSystem/CPK/CPKDataFormat.cs index b30df5bf..4e9fa85b 100644 --- a/Plugins/UniversalEditor.Plugins.CRI/DataFormats/FileSystem/CPK/CPKDataFormat.cs +++ b/Plugins/UniversalEditor.Plugins.CRI/DataFormats/FileSystem/CPK/CPKDataFormat.cs @@ -268,7 +268,15 @@ namespace UniversalEditor.Plugins.CRI.DataFormats.FileSystem.CPK uint decompressedLength = (uint)dtUTFTOC.Records[i].Fields["FileSize"].Value; uint compressedLength = (uint)dtUTFTOC.Records[i].Fields["ExtractSize"].Value; ulong offset = (ulong)dtUTFTOC.Records[i].Fields["FileOffset"].Value; + + ulong lTocOffset = (ulong)dtUTF.Records[0].Fields["TocOffset"].Value; ulong lContentOffset = (ulong)dtUTF.Records[0].Fields["ContentOffset"].Value; + + // HACK: according to kamikat cpk tools, the real content offset is whichever is smaller TocOffset vs ContentOffset + // https://github.com/kamikat/cpktools/blob/master/cpkunpack.py + // this feels EXTREMELY hacky, but it works... for now + ulong lRealContentOffset = Math.Min(lTocOffset, lContentOffset); + offset += lContentOffset; File f = fsom.AddFile(fileName);