[Scummvm-cvs-logs] SF.net SVN: scummvm: [33068] scummvm/trunk/engines/cine

buddha_ at users.sourceforge.net buddha_ at users.sourceforge.net
Tue Jul 15 01:10:51 CEST 2008


Revision: 33068
          http://scummvm.svn.sourceforge.net/scummvm/?rev=33068&view=rev
Author:   buddha_
Date:     2008-07-14 16:10:51 -0700 (Mon, 14 Jul 2008)

Log Message:
-----------
Fix for bug #2016647 (FW: crash with italian amiga version).
- Consists of a workaround for a script bug that used local
  variable 251 when it should've used global variable 251.
- Also added a fix for a crash when failing copy protection
  in Amiga or Atari ST versions of Future Wars.
NOTE: That any of the Amiga or Atari ST versions of Future Wars
haven't crashed right in the beginning before seems like plain
luck because accessing local variable 251 is out of bounds!

Modified Paths:
--------------
    scummvm/trunk/engines/cine/cine.h
    scummvm/trunk/engines/cine/prc.cpp
    scummvm/trunk/engines/cine/prc.h
    scummvm/trunk/engines/cine/script_fw.cpp
    scummvm/trunk/engines/cine/various.cpp

Modified: scummvm/trunk/engines/cine/cine.h
===================================================================
--- scummvm/trunk/engines/cine/cine.h	2008-07-14 22:43:01 UTC (rev 33067)
+++ scummvm/trunk/engines/cine/cine.h	2008-07-14 23:10:51 UTC (rev 33068)
@@ -107,6 +107,7 @@
 extern CineEngine *g_cine;
 
 #define BOOT_PRC_NAME "AUTO00.PRC"
+#define COPY_PROT_FAIL_PRC_NAME "L201.ANI"
 
 enum {
 	VAR_MOUSE_X_MODE = 253,

Modified: scummvm/trunk/engines/cine/prc.cpp
===================================================================
--- scummvm/trunk/engines/cine/prc.cpp	2008-07-14 22:43:01 UTC (rev 33067)
+++ scummvm/trunk/engines/cine/prc.cpp	2008-07-14 23:10:51 UTC (rev 33068)
@@ -40,8 +40,9 @@
 
 /*! \todo Is script size of 0 valid?
  * \todo Fix script dump code
+ * @return Was the loading successful?
  */
-void loadPrc(const char *pPrcName) {
+bool loadPrc(const char *pPrcName) {
 	byte i;
 	uint16 numScripts;
 	byte *scriptPtr, *dataPtr;
@@ -52,9 +53,9 @@
 	scriptTable.clear();
 
 	// This is copy protection. Used to hang the machine
-	if (!scumm_stricmp(pPrcName, "L201.ANI")) {
+	if (!scumm_stricmp(pPrcName, COPY_PROT_FAIL_PRC_NAME)) {
 		exitEngine = 1;
-		return;
+		return false;
 	}
 
 	checkDataDisk(-1);
@@ -107,6 +108,8 @@
 		}
 	}
 #endif
+
+	return true;
 }
 
 } // End of namespace Cine

Modified: scummvm/trunk/engines/cine/prc.h
===================================================================
--- scummvm/trunk/engines/cine/prc.h	2008-07-14 22:43:01 UTC (rev 33067)
+++ scummvm/trunk/engines/cine/prc.h	2008-07-14 23:10:51 UTC (rev 33068)
@@ -31,7 +31,7 @@
 extern ScriptList globalScripts;
 extern ScriptList objectScripts;
 
-void loadPrc(const char *pPrcName);
+bool loadPrc(const char *pPrcName);
 
 } // End of namespace Cine
 

Modified: scummvm/trunk/engines/cine/script_fw.cpp
===================================================================
--- scummvm/trunk/engines/cine/script_fw.cpp	2008-07-14 22:43:01 UTC (rev 33067)
+++ scummvm/trunk/engines/cine/script_fw.cpp	2008-07-14 23:10:51 UTC (rev 33068)
@@ -1019,6 +1019,20 @@
 }
 
 int FWScript::o1_compareVar() {
+	// WORKAROUND: A workaround for a script bug in script file CODE2.PRC
+	// in at least some of the Amiga and Atari ST versions of Future Wars.
+	// Fixes bug #2016647 (FW: crash with italian amiga version). A local
+	// variable 251 is compared against value 0 although it's quite apparent
+	// from the context in the script that instead global variable 251 should
+	// be compared against value 0. So looks like someone made a typo when
+	// making the scripts. Therefore we change that particular comparison
+	// from using the local variable 251 to using the global variable 251.
+	if (g_cine->getGameType() == Cine::GType_FW && scumm_stricmp(currentPrcName, "CODE2.PRC") == 0 &&
+		(g_cine->getPlatform() == Common::kPlatformAmiga || g_cine->getPlatform() == Common::kPlatformAtariST) &&
+		_script.getByte(_pos) == 251 && _script.getByte(_pos + 1) == 0 && _script.getWord(_pos + 2) == 0) {
+		return o1_compareGlobalVar();
+	}
+
 	byte varIdx = getNextByte();
 	byte varType = getNextByte();
 

Modified: scummvm/trunk/engines/cine/various.cpp
===================================================================
--- scummvm/trunk/engines/cine/various.cpp	2008-07-14 22:43:01 UTC (rev 33067)
+++ scummvm/trunk/engines/cine/various.cpp	2008-07-14 23:10:51 UTC (rev 33068)
@@ -1518,12 +1518,22 @@
 
 void checkForPendingDataLoad(void) {
 	if (newPrcName[0] != 0) {
-		loadPrc(newPrcName);
+		bool loadPrcOk = loadPrc(newPrcName);
 
 		strcpy(currentPrcName, newPrcName);
 		strcpy(newPrcName, "");
 
-		addScriptToList0(1);
+		// Check that the loading of the script file was successful before
+		// trying to add script 1 from it to the global scripts list. This
+		// fixes a crash when failing copy protection in Amiga or Atari ST
+		// versions of Future Wars.
+		if (loadPrcOk) {
+			addScriptToList0(1);
+		} else if (scumm_stricmp(currentPrcName, COPY_PROT_FAIL_PRC_NAME)) {
+			// We only show an error here for other files than the file that
+			// is loaded if copy protection fails (i.e. L201.ANI).
+			warning("checkForPendingDataLoad: loadPrc(%s) failed", currentPrcName);
+		}
 	}
 
 	if (newRelName[0] != 0) {


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