[Scummvm-cvs-logs] SF.net SVN: scummvm: [25690] scummvm/trunk/backends/saves/compressed/ compressed-saves.cpp

marcus_c at users.sourceforge.net marcus_c at users.sourceforge.net
Sun Feb 18 17:55:41 CET 2007


Revision: 25690
          http://scummvm.svn.sourceforge.net/scummvm/?rev=25690&view=rev
Author:   marcus_c
Date:     2007-02-18 08:55:40 -0800 (Sun, 18 Feb 2007)

Log Message:
-----------
Accept zlib format files as well when reading.

Modified Paths:
--------------
    scummvm/trunk/backends/saves/compressed/compressed-saves.cpp

Modified: scummvm/trunk/backends/saves/compressed/compressed-saves.cpp
===================================================================
--- scummvm/trunk/backends/saves/compressed/compressed-saves.cpp	2007-02-18 16:01:55 UTC (rev 25689)
+++ scummvm/trunk/backends/saves/compressed/compressed-saves.cpp	2007-02-18 16:55:40 UTC (rev 25690)
@@ -59,11 +59,18 @@
 		
 		// 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 @@
 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);


This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.




More information about the Scummvm-git-logs mailing list