From 138b7bea41f0e24d3cde41253f59d0f32ab2dbda Mon Sep 17 00:00:00 2001 From: Marcus Comstedt Date: Sun, 18 Feb 2007 16:55:40 +0000 Subject: Accept zlib format files as well when reading. svn-id: r25690 --- backends/saves/compressed/compressed-saves.cpp | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) (limited to 'backends') diff --git a/backends/saves/compressed/compressed-saves.cpp b/backends/saves/compressed/compressed-saves.cpp index 183e8dd355..48b7cfff79 100644 --- a/backends/saves/compressed/compressed-saves.cpp +++ b/backends/saves/compressed/compressed-saves.cpp @@ -59,11 +59,18 @@ public: // Verify file header is correct once more w->seek(0, SEEK_SET); - assert(w->readUint16BE() == 0x1F8B); + uint16 header = w->readUint16BE(); + assert(header == 0x1F8B || + ((header & 0x0F00) == 0x0800 && header % 31 == 0)); - // Retrieve the original file size - w->seek(-4, SEEK_END); - _origSize = w->readUint32LE(); + if(header == 0x1F8B) { + // Retrieve the original file size + w->seek(-4, SEEK_END); + _origSize = w->readUint32LE(); + } else { + // Original size not available in zlib format + _origSize = 0; + } _pos = 0; w->seek(0, SEEK_SET); @@ -261,7 +268,10 @@ public: Common::InSaveFile *wrapInSaveFile(Common::InSaveFile *toBeWrapped) { #if defined(USE_ZLIB) if (toBeWrapped) { - bool isCompressed = (toBeWrapped->readUint16BE() == 0x1F8B); + uint16 header = toBeWrapped->readUint16BE(); + bool isCompressed = (header == 0x1F8B || + ((header & 0x0F00) == 0x0800 && + header % 31 == 0)); toBeWrapped->seek(-2, SEEK_CUR); if (isCompressed) return new CompressedInSaveFile(toBeWrapped); -- cgit v1.2.3