[Scummvm-cvs-logs] SF.net SVN: scummvm:[34576] scummvm/trunk

fingolfin at users.sourceforge.net fingolfin at users.sourceforge.net
Tue Sep 16 13:42:22 CEST 2008


Revision: 34576
          http://scummvm.svn.sourceforge.net/scummvm/?rev=34576&view=rev
Author:   fingolfin
Date:     2008-09-16 11:42:21 +0000 (Tue, 16 Sep 2008)

Log Message:
-----------
Modified uncompress in common/zlib.h to return a bool, so that we don't have to #include the real zlib.h; fixed PSP backend to not run uncompress inside an assert (which would cause it to not be invoked when turning off asserts)

Modified Paths:
--------------
    scummvm/trunk/backends/platform/psp/osys_psp_gu.cpp
    scummvm/trunk/common/zlib.cpp
    scummvm/trunk/common/zlib.h
    scummvm/trunk/engines/agos/res.cpp
    scummvm/trunk/engines/scumm/smush/smush_player.cpp

Modified: scummvm/trunk/backends/platform/psp/osys_psp_gu.cpp
===================================================================
--- scummvm/trunk/backends/platform/psp/osys_psp_gu.cpp	2008-09-16 10:53:57 UTC (rev 34575)
+++ scummvm/trunk/backends/platform/psp/osys_psp_gu.cpp	2008-09-16 11:42:21 UTC (rev 34576)
@@ -94,19 +94,24 @@
 	//decompress keyboard data
 	uLongf kbdSize = KBD_DATA_SIZE;
 	keyboard_letters = (unsigned char *)memalign(16, KBD_DATA_SIZE);
-	assert(Z_OK == uncompress((Bytef *)keyboard_letters, &kbdSize, (const Bytef *)keyboard_letters_compressed, size_keyboard_letters_compressed));
-
+	assert(Z_OK == 
+	if (!uncompress((Bytef *)keyboard_letters, &kbdSize, (const Bytef *)keyboard_letters_compressed, size_keyboard_letters_compressed))
+		error("OSystem_PSP_GU: uncompressing keyboard_letters failed");
+		
 	kbdSize = KBD_DATA_SIZE;
 	keyboard_letters_shift = (unsigned char *)memalign(16, KBD_DATA_SIZE);
-	assert(Z_OK == uncompress((Bytef *)keyboard_letters_shift, &kbdSize, (const Bytef *)keyboard_letters_shift_compressed, size_keyboard_letters_shift_compressed));
+	if (!uncompress((Bytef *)keyboard_letters_shift, &kbdSize, (const Bytef *)keyboard_letters_shift_compressed, size_keyboard_letters_shift_compressed))
+		error("OSystem_PSP_GU: uncompressing keyboard_letters_shift failed");
 
 	kbdSize = KBD_DATA_SIZE;
 	keyboard_symbols = (unsigned char *)memalign(16, KBD_DATA_SIZE);
-	assert(Z_OK == uncompress((Bytef *)keyboard_symbols, &kbdSize, (const Bytef *)keyboard_symbols_compressed, size_keyboard_symbols_compressed));
+	if (!uncompress((Bytef *)keyboard_symbols, &kbdSize, (const Bytef *)keyboard_symbols_compressed, size_keyboard_symbols_compressed))
+		error("OSystem_PSP_GU: uncompressing keyboard_symbols failed");
 
 	kbdSize = KBD_DATA_SIZE;
 	keyboard_symbols_shift = (unsigned char *)memalign(16, KBD_DATA_SIZE);
-	assert(Z_OK == uncompress((Bytef *)keyboard_symbols_shift, &kbdSize, (const Bytef *)keyboard_symbols_shift_compressed, size_keyboard_symbols_shift_compressed));
+	if (!uncompress((Bytef *)keyboard_symbols_shift, &kbdSize, (const Bytef *)keyboard_symbols_shift_compressed, size_keyboard_symbols_shift_compressed))
+		error("OSystem_PSP_GU: uncompressing keyboard_symbols_shift failed");
 
 	_keyboardVisible = false;
 	_clut = (unsigned short*)(((unsigned int)clut256)|0x40000000);

Modified: scummvm/trunk/common/zlib.cpp
===================================================================
--- scummvm/trunk/common/zlib.cpp	2008-09-16 10:53:57 UTC (rev 34575)
+++ scummvm/trunk/common/zlib.cpp	2008-09-16 11:42:21 UTC (rev 34576)
@@ -34,8 +34,8 @@
 
 namespace Common {
 
-int uncompress(byte *dst, unsigned long *dstLen, const byte *src, unsigned long srcLen) {
-	return ::uncompress(dst, dstLen, src, srcLen);
+bool uncompress(byte *dst, unsigned long *dstLen, const byte *src, unsigned long srcLen) {
+	return Z_OK == ::uncompress(dst, dstLen, src, srcLen);
 }
 
 } // end of namespace Common

Modified: scummvm/trunk/common/zlib.h
===================================================================
--- scummvm/trunk/common/zlib.h	2008-09-16 10:53:57 UTC (rev 34575)
+++ scummvm/trunk/common/zlib.h	2008-09-16 11:42:21 UTC (rev 34576)
@@ -22,27 +22,24 @@
  * $Id$
  */
 
-#include "common/scummsys.h"
-
-#if defined(USE_ZLIB)
-
 #ifndef COMMON_ZLIB_H
 #define COMMON_ZLIB_H
 
-#ifdef __SYMBIAN32__
-#include <zlib\zlib.h>
-#else
-#include <zlib.h>
-#endif
+#include "common/scummsys.h"
 
+#if defined(USE_ZLIB)
+
 namespace Common {
 
-enum {
-	ZLIB_OK = Z_OK
-};
+/**
+ * Thin wrapper around zlib's uncompress() function. This wrapper makes
+ * it possible to uncompress data in engines without being forced to link
+ * them against zlib, thus simplifying the build system.
+ * 
+ * @return true on success (i.e. Z_OK), false otherwise
+ */
+bool uncompress(byte *dst, unsigned long *dstLen, const byte *src, unsigned long srcLen);
 
-int uncompress(byte *dst, unsigned long *dstLen, const byte *src, unsigned long srcLen);
-
 } // end of namespace Common
 
 #endif

Modified: scummvm/trunk/engines/agos/res.cpp
===================================================================
--- scummvm/trunk/engines/agos/res.cpp	2008-09-16 10:53:57 UTC (rev 34575)
+++ scummvm/trunk/engines/agos/res.cpp	2008-09-16 11:42:21 UTC (rev 34576)
@@ -74,8 +74,7 @@
 				error("decompressData: Read failed");
 
 			unsigned long decompressedSize = dstSize;
-			int result = Common::uncompress(dst, &decompressedSize, srcBuffer, srcSize);
-			if (result != Common::ZLIB_OK)
+			if (!Common::uncompress(dst, &decompressedSize, srcBuffer, srcSize))
 				error("decompressData: Zlib uncompress error");
 			free(srcBuffer);
 		} else {

Modified: scummvm/trunk/engines/scumm/smush/smush_player.cpp
===================================================================
--- scummvm/trunk/engines/scumm/smush/smush_player.cpp	2008-09-16 10:53:57 UTC (rev 34575)
+++ scummvm/trunk/engines/scumm/smush/smush_player.cpp	2008-09-16 11:42:21 UTC (rev 34576)
@@ -791,8 +791,7 @@
 
 	unsigned long decompressedSize = READ_BE_UINT32(chunkBuffer);
 	byte *fobjBuffer = (byte *)malloc(decompressedSize);
-	int result = Common::uncompress(fobjBuffer, &decompressedSize, chunkBuffer + 4, chunkSize - 4);
-	if (result != Common::ZLIB_OK)
+	if (!Common::uncompress(fobjBuffer, &decompressedSize, chunkBuffer + 4, chunkSize - 4))
 		error("SmushPlayer::handleZlibFrameObject() Zlib uncompress error");
 	free(chunkBuffer);
 


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