Slightly alter ARM9 compression detection.

Fixes #2
This commit is contained in:
Admiral H. Curtiss 2015-03-24 21:05:29 +01:00
parent f90c4491c2
commit f1e728a2dd

View File

@ -89,7 +89,7 @@ namespace WfcPatcher {
nds.Position = nds.Position - 8;
uint compressedSize = nds.ReadUInt24();
nds.ReadByte();
byte headerLength = (byte)nds.ReadByte();
uint additionalCompressedSize = nds.ReadUInt32();
uint decompressedSize = additionalCompressedSize + len;
@ -106,8 +106,10 @@ namespace WfcPatcher {
#endif
blz blz = new blz();
// if this condition isn't true then it can't be blz-compressed so don't even try
if ( data.Length == compressedSize + 0x4000 || data.Length == compressedSize + 0x4004 ) {
// if one of these isn't true then it can't be blz-compressed so don't even try
bool headerLengthValid = ( headerLength >= 8 && headerLength <= 11 );
bool compressedSizeValid = ( data.Length >= compressedSize + 0x4000 && data.Length <= compressedSize + 0x400B );
if ( headerLengthValid && compressedSizeValid ) {
try {
blz.arm9 = 1;
byte[] maybeDecData = blz.BLZ_Decode( data );