[Scummvm-cvs-logs] SF.net SVN: scummvm:[46138] scummvm/trunk/engines/saga

sev at users.sourceforge.net sev at users.sourceforge.net
Wed Nov 25 21:43:55 CET 2009


Revision: 46138
          http://scummvm.svn.sourceforge.net/scummvm/?rev=46138&view=rev
Author:   sev
Date:     2009-11-25 20:43:49 +0000 (Wed, 25 Nov 2009)

Log Message:
-----------
Cache resource file size to avoid excess file->size() calls.

Modified Paths:
--------------
    scummvm/trunk/engines/saga/resource.cpp
    scummvm/trunk/engines/saga/resource.h
    scummvm/trunk/engines/saga/resource_rsc.cpp

Modified: scummvm/trunk/engines/saga/resource.cpp
===================================================================
--- scummvm/trunk/engines/saga/resource.cpp	2009-11-25 18:05:39 UTC (rev 46137)
+++ scummvm/trunk/engines/saga/resource.cpp	2009-11-25 20:43:49 UTC (rev 46138)
@@ -95,7 +95,7 @@
 			resourceData->offset = contextOffset + readS1.readUint32();
 			resourceData->size = readS1.readUint32();
 			//sanity check
-			if ((resourceData->offset > (uint)context->file->size()) || (resourceData->size > contextSize)) {
+			if ((resourceData->offset > (uint)context->fileSize) || (resourceData->size > contextSize)) {
 				result = false;
 				break;
 			}
@@ -123,6 +123,7 @@
 		return false;
 	}
 
+	context->fileSize = context->file->size();
 	context->isBigEndian = _vm->isBigEndian();
 
 	if (context->fileType & GAME_SWAPENDIAN)
@@ -132,7 +133,7 @@
 	context->fileType &= ~GAME_MACBINARY;
 
 	if (!isMacBinary) {
-		if (!loadResContext(context, 0, context->file->size())) {
+		if (!loadResContext(context, 0, context->fileSize)) {
 			return false;
 		}
 	} else {

Modified: scummvm/trunk/engines/saga/resource.h
===================================================================
--- scummvm/trunk/engines/saga/resource.h	2009-11-25 18:05:39 UTC (rev 46137)
+++ scummvm/trunk/engines/saga/resource.h	2009-11-25 20:43:49 UTC (rev 46138)
@@ -69,6 +69,7 @@
 	const char *fileName;
 	uint16 fileType;
 	Common::File *file;
+	int32 fileSize;
 	int serial;			// IHNM speech files
 
 	bool isCompressed;

Modified: scummvm/trunk/engines/saga/resource_rsc.cpp
===================================================================
--- scummvm/trunk/engines/saga/resource_rsc.cpp	2009-11-25 18:05:39 UTC (rev 46137)
+++ scummvm/trunk/engines/saga/resource_rsc.cpp	2009-11-25 20:43:49 UTC (rev 46138)
@@ -98,7 +98,7 @@
 	byte macNameLen;
 	bool notSagaContext = false;
 
-	if (context->file->size() < RSC_MIN_FILESIZE + MAC_BINARY_HEADER_SIZE) {
+	if (context->fileSize < RSC_MIN_FILESIZE + MAC_BINARY_HEADER_SIZE) {
 		return false;
 	}
 
@@ -128,8 +128,8 @@
 	macDataLength = context->file->readUint32BE();
 	macMapLength = context->file->readUint32BE();
 
-	if (macDataOffset >= (uint)context->file->size() || macMapOffset >= (uint)context->file->size() ||
-		macDataLength + macMapLength > (uint)context->file->size()) {
+	if (macDataOffset >= (uint)context->fileSize || macMapOffset >= (uint)context->fileSize ||
+		macDataLength + macMapLength > (uint)context->fileSize) {
 			return false;
 	}
 


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