Skip to content

Commit

Permalink
fix compression detection
Browse files Browse the repository at this point in the history
  • Loading branch information
Frotty committed Jan 21, 2018
1 parent 5a1732f commit 43b5d66
Showing 1 changed file with 8 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -39,15 +39,19 @@ public static byte[] decompress(byte[] sector, int compressedSize, int uncompres
in.position(1);

boolean flip = false;
boolean isLMZACompressed = (compressionType & FLAG_LMZA) != 0;
boolean isLZMACompressed = (compressionType & FLAG_LMZA) != 0;
boolean isBzip2Compressed = (compressionType & FLAG_BZIP2) != 0;
boolean isImploded = (compressionType & FLAG_IMPLODE) != 0;
boolean isSparseCompressed = (compressionType & FLAG_SPARSE) != 0;
boolean isDeflated = (compressionType & FLAG_DEFLATE) != 0;
boolean isHuffmanCompressed = (compressionType & FLAG_HUFFMAN) != 0;

if (isLMZACompressed) {
throw new JMpqException("Unsupported compression Bzip2");
if (isDeflated) {
out.put(JzLibHelper.inflate(sector, 1, uncompressedSize));
out.position(0);
flip = !flip;
} else if (isLZMACompressed) {
throw new JMpqException("Unsupported compression LZMA");
} else if (isBzip2Compressed) {
throw new JMpqException("Unsupported compression Bzip2");
} else if (isImploded) {
Expand All @@ -60,11 +64,7 @@ public static byte[] decompress(byte[] sector, int compressedSize, int uncompres
if (isSparseCompressed) {
throw new JMpqException("Unsupported compression sparse");
}
if (isDeflated) {
out.put(JzLibHelper.inflate(sector, 1, uncompressedSize));
out.position(0);
flip = !flip;
}

if (isHuffmanCompressed) {
if (huffman == null) {
huffman = new Huffman();
Expand Down

0 comments on commit 43b5d66

Please sign in to comment.