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

m_kiewitz at users.sourceforge.net m_kiewitz at users.sourceforge.net
Wed May 26 22:48:09 CEST 2010


Revision: 49250
          http://scummvm.svn.sourceforge.net/scummvm/?rev=49250&view=rev
Author:   m_kiewitz
Date:     2010-05-26 20:48:08 +0000 (Wed, 26 May 2010)

Log Message:
-----------
SCI: fixing kReadNumber to behave like in sierra sci (non standard atoi implementation) - fixes big door not unlocking in sq4

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

Modified: scummvm/trunk/engines/sci/engine/kstring.cpp
===================================================================
--- scummvm/trunk/engines/sci/engine/kstring.cpp	2010-05-26 19:54:50 UTC (rev 49249)
+++ scummvm/trunk/engines/sci/engine/kstring.cpp	2010-05-26 20:48:08 UTC (rev 49250)
@@ -138,10 +138,28 @@
 	while (isspace((unsigned char)*source))
 		source++; /* Skip whitespace */
 
-	if (*source == '$') /* SCI uses this for hex numbers */
-		return make_reg(0, (int16)strtol(source + 1, NULL, 16)); /* Hex */
-	else
-		return make_reg(0, (int16)strtol(source, NULL, 10)); /* Force decimal */
+	int16 result = 0;
+
+	if (*source == '$') {
+		// hexadecimal input
+		result = (int16)strtol(source + 1, NULL, 16);
+	} else {
+		// decimal input, we can not use strtol/atoi in here, because sierra used atoi BUT it was a non standard compliant
+		//  atoi, that didnt do clipping. In SQ4 we get the door code in here and that's even larger than uint32!
+		if (*source == '-') {
+			result = -1;
+			source++;
+		}
+		while (*source) {
+			result *= 10;
+			if ((*source < '0') || (*source > '9'))
+				error("Invalid character in kReadNumber input");
+			result += *source - 0x30;
+			source++;
+		}
+	}
+
+	return make_reg(0, result);
 }
 
 


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