public override LoadMatchStrength LoadMatch(AssetLoader info)
{
var reader = info.Reader;
long length = reader.BaseStream.Length;
if (length < 2)
return LoadMatchStrength.None;
int headerLength = reader.ReadUInt16();
if (headerLength == 0 || headerLength % ArchiveRecord.HeaderSize != 0 || length < headerLength + 2)
return LoadMatchStrength.None;
int dataOffset = headerLength + 2;
int currentOffset = dataOffset;
for (int index = 0; index < headerLength / 9; index++) {
byte id = reader.ReadByte();
int offset = reader.ReadInt32() + dataOffset;
int uncompressedSize = reader.ReadUInt16();
int compressedSize = reader.ReadUInt16();
if (offset != currentOffset)
return LoadMatchStrength.None;
currentOffset += compressedSize;
// Offset is out of the file.
if (offset > length)
return LoadMatchStrength.None;
// File is empty but one of the sizes is not.
if (compressedSize == 0 || uncompressedSize == 0)
return LoadMatchStrength.None;
// Uncompressed expansion can't be used as a metric. I tried; some files expand one out of seven bytes. It's nuts how bad their RLE compressor was. At a guess it stopped a data run for every repeating byte, resulting in far more data runs when only a repeat run of 4 or more is guaranteed to result in compression (because then you've saved at least two bytes, accounting for your repeat run length and the next run length bytes).
}
return LoadMatchStrength.Strong;
}