[Scummvm-cvs-logs] SF.net SVN: scummvm:[49394] scummvm/trunk/engines/sci/engine/segment.cpp

thebluegr at users.sourceforge.net thebluegr at users.sourceforge.net
Wed Jun 2 17:31:20 CEST 2010


Revision: 49394
          http://scummvm.svn.sourceforge.net/scummvm/?rev=49394&view=rev
Author:   thebluegr
Date:     2010-06-02 15:31:20 +0000 (Wed, 02 Jun 2010)

Log Message:
-----------
Fixed regression from commit #49332 (merging of the SCI0 and SCI11 relocate functions, where the SCI0 equivalent had a +1 count): it seems that we should skip over zero exports, however the total number of valid exports remains the same. Fixes KQ5 and QFG2. This also fixes the relocation calculation of script 71 in SQ3, so remove the comment that the script has broken relocation entries

Modified Paths:
--------------
    scummvm/trunk/engines/sci/engine/segment.cpp

Modified: scummvm/trunk/engines/sci/engine/segment.cpp
===================================================================
--- scummvm/trunk/engines/sci/engine/segment.cpp	2010-06-02 15:26:35 UTC (rev 49393)
+++ scummvm/trunk/engines/sci/engine/segment.cpp	2010-06-02 15:31:20 UTC (rev 49394)
@@ -101,7 +101,7 @@
 	_localsSegment = 0;
 	_localsBlock = NULL;
 
-	_markedAsDeleted = 0;
+	_markedAsDeleted = false;
 }
 
 Script::~Script() {
@@ -306,17 +306,20 @@
 	       "Relocation block outside of script\n");
 
 	int count = READ_SCI11ENDIAN_UINT16(heap + block.offset);
+	int exportIndex = 0;
 
 	for (int i = 0; i < count; i++) {
-		int pos = READ_SCI11ENDIAN_UINT16(heap + block.offset + 2 + (i * 2)) + heapOffset;
-		// This occurs in SCI01/SCI1 games where every other export
-		// value is zero. I have no idea what it's supposed to mean.
-		//
-		// Yes, there is code in the original to handle this situation,
-		// but we need an example of it happening in order to determine
-		// what to do.
-		if (!pos)
-			continue; // FIXME: Just ignore it for now.
+		int pos = READ_SCI11ENDIAN_UINT16(heap + block.offset + 2 + (exportIndex * 2)) + heapOffset;
+		// This occurs in SCI01/SCI1 games where every usually one export
+		// value is zero. It seems that in this situation, we should skip
+		// the export and move to the next one, though the total count
+		// of valid exports remains the same
+		if (!pos) {
+			exportIndex++;
+			pos = READ_SCI11ENDIAN_UINT16(heap + block.offset + 2 + (exportIndex * 2)) + heapOffset;
+			if (!pos)
+				error("Script::relocate(): Consecutive zero exports found");
+		}
 
 		if (!relocateLocal(block.segment, pos)) {
 			bool done = false;
@@ -339,18 +342,19 @@
 			}
 
 			if (!done) {
-				printf("While processing relocation block %04x:%04x:\n", PRINT_REG(block));
-				printf("Relocation failed for index %04x (%d/%d)\n", pos, i + 1, count);
+				debug("While processing relocation block %04x:%04x:\n", PRINT_REG(block));
+				debug("Relocation failed for index %04x (%d/%d)\n", pos, exportIndex + 1, count);
 				if (_localsBlock)
-					printf("- locals: %d at %04x\n", _localsBlock->_locals.size(), _localsOffset);
+					debug("- locals: %d at %04x\n", _localsBlock->_locals.size(), _localsOffset);
 				else
-					printf("- No locals\n");
+					debug("- No locals\n");
 				for (it = _objects.begin(), k = 0; it != end; ++it, ++k)
-					printf("- obj#%d at %04x w/ %d vars\n", k, it->_value.getPos().offset, it->_value.getVarCount());
-				// SQ3 script 71 has broken relocation entries.
-				printf("Trying to continue anyway...\n");
+					debug("- obj#%d at %04x w/ %d vars\n", k, it->_value.getPos().offset, it->_value.getVarCount());
+				debug("Trying to continue anyway...\n");
 			}
 		}
+
+		exportIndex++;
 	}
 }
 


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