PACx : fix some freezes loading type 0 files (root single chunks)

This commit is contained in:
KillzXGaming 2020-07-26 12:30:21 -04:00
parent cdc0049190
commit bebba0e432

View file

@ -82,7 +82,20 @@ namespace HedgehogLibrary
if (IsVersion4)
{
var header = reader.ReadStruct<HeaderV4>();
var chunks = reader.ReadMultipleStructs<Chunk>(header.ChunkCount);
List<Chunk> chunks = new List<Chunk>();
if (header.Type != (PacType)0)
{
uint chunkCount = reader.ReadUInt32();
chunks = reader.ReadMultipleStructs<Chunk>(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)]