Your first problem is that you should not modify the data; just get rid of [::-1] .
But if you do, instead of getting this -3 error, you will get another -3 error, usually about an unknown compression method.
The problem is that this is data without a zlib header, similar to what gzip uses. Theoretically, this means that information about the compression method, window, start dict, etc. Must be provided somewhere else in the file (in the case of gzip according to the information in the gzip header). But in practice, everyone uses deflate with the maximum window size and no dict beginning, so if I were developing a compact format for the game on the days when every byte counted, I would just hard code them. (Nowadays, this is exactly what was standardized in the RFC as the "DEFLATE Compressed Data Format", but most computer games of the 90s did not match the RFC in design ...)
So:
>>> uncompressed_data = zlib.decompress(compressed_data, -zlib.MAX_WBITS) >>> uncompressed_data[:8]
So, itβs not only unpacked, it looks like a version and ... well, I think something looks like an unknown constant, but it is the same unknown constant in the specification, so I think we are good.
As decompress shows, MAX_WBITS is the standard / most common window size (and the only size used by what is commonly called "zlib deflate" as opposed to "zlib"), and passing a negative value means that the header is suppressed; other arguments that we can leave as default.
See also this answer , Advanced Features section in zlib docs and RFC 1951 . (Thanks to OP for finding links.)
abarnert
source share