From bebba0e432cad00ebb2445ffadc41815ac907e77 Mon Sep 17 00:00:00 2001 From: KillzXGaming Date: Sun, 26 Jul 2020 12:30:21 -0400 Subject: [PATCH] PACx : fix some freezes loading type 0 files (root single chunks) --- .../FileFormats/HedgehogEngine/PACx.cs | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/File_Format_Library/FileFormats/HedgehogEngine/PACx.cs b/File_Format_Library/FileFormats/HedgehogEngine/PACx.cs index ee94e14a..bacb82af 100644 --- a/File_Format_Library/FileFormats/HedgehogEngine/PACx.cs +++ b/File_Format_Library/FileFormats/HedgehogEngine/PACx.cs @@ -82,7 +82,20 @@ namespace HedgehogLibrary if (IsVersion4) { var header = reader.ReadStruct(); - var chunks = reader.ReadMultipleStructs(header.ChunkCount); + + List chunks = new List(); + if (header.Type != (PacType)0) + { + uint chunkCount = reader.ReadUInt32(); + chunks = reader.ReadMultipleStructs(chunkCount); + } + else + chunks.Add(new Chunk() + { + CompressedSize = header.RootCompressedSize, + UncompressedSize = header.RootUncompressedSize + }); + Checksum = header.PacID; //Decompress each chunk now @@ -226,7 +239,6 @@ namespace HedgehogLibrary public uint RootUncompressedSize; public PacType Type = PacType.HasNoSplit; public ushort Constant = 0x208; - public uint ChunkCount; } [StructLayout(LayoutKind.Sequential, Pack = 1)]