@@ -1892,49 +1892,49 @@ struct LZOLoadFilter : LoadFilter {
uint32 tmp[2];
uint32 size;
lzo_uint len;
/* Read header*/
if (this->chain->Read((byte*)tmp, sizeof(tmp)) != sizeof(tmp)) SlError(STR_GAME_SAVELOAD_ERROR_FILE_NOT_READABLE, "File read failed");
/* Check if size is bad */
((uint32*)out)[0] = size = tmp[1];
if (_sl_version != 0) {
tmp[0] = TO_BE32(tmp[0]);
size = TO_BE32(size);
}
if (size >= sizeof(out)) SlErrorCorrupt("Inconsistent size");
/* Read block */
if (this->chain->Read(out + sizeof(uint32), size) != size) SlError(STR_GAME_SAVELOAD_ERROR_FILE_NOT_READABLE);
/* Verify checksum */
if (tmp[0] != lzo_adler32(0, out, size + sizeof(uint32))) SlErrorCorrupt("Bad checksum");
/* Decompress */
lzo1x_decompress(out + sizeof(uint32) * 1, size, buf, &len, NULL);
lzo1x_decompress_safe(out + sizeof(uint32) * 1, size, buf, &len, NULL);
return len;
};
/** Filter using LZO compression. */
struct LZOSaveFilter : SaveFilter {
/**
* Initialise this filter.
* @param chain The next filter in this chain.
* @param compression_level The requested level of compression.
*/
LZOSaveFilter(SaveFilter *chain, byte compression_level) : SaveFilter(chain)
{
if (lzo_init() != LZO_E_OK) SlError(STR_GAME_SAVELOAD_ERROR_BROKEN_INTERNAL_ERROR, "cannot initialize compressor");
/* virtual */ void Write(byte *buf, size_t size)
const lzo_bytep in = buf;
/* Buffer size is from the LZO docs plus the chunk header size. */
byte out[LZO_BUFFER_SIZE + LZO_BUFFER_SIZE / 16 + 64 + 3 + sizeof(uint32) * 2];
byte wrkmem[LZO1X_1_MEM_COMPRESS];
lzo_uint outlen;
Status change: