public override void Construct(BinaryEndianReader br, QbItemType type)
{
//System.Diagnostics.Debug.WriteLine(string.Format("{0} - 0x{1}", type.ToString(), (base.StreamPos(br) - 4).ToString("X").PadLeft(8, '0')));
base.Construct(br, type);
_unknown = br.ReadUInt32(base.Root.PakFormat.EndianType);
uint decompressedSize = br.ReadUInt32(base.Root.PakFormat.EndianType);
uint compressedSize = br.ReadUInt32(base.Root.PakFormat.EndianType);
// Get script data
Lzss lz = new Lzss();
_scriptData = br.ReadBytes((int)compressedSize);
if (compressedSize < decompressedSize)
{
_scriptData = lz.Decompress(_scriptData);
}
if (_scriptData.Length != decompressedSize)
{
throw new ApplicationException(string.Format("Location 0x{0}: Script decompressed to {1} bytes not {2}", (base.StreamPos(br) - compressedSize).ToString("X").PadLeft(8, '0'), _scriptData.Length.ToString(), decompressedSize.ToString()));
}
// Padding...
if ((base.StreamPos(br) % 4) != 0)
{
br.BaseStream.Seek(4 - (base.StreamPos(br) % 4), SeekOrigin.Current);
}
base.ConstructEnd(br);
}