[Scummvm-cvs-logs] SF.net SVN: scummvm: [29799] scummvm/trunk/engines/parallaction/gui_ns.cpp

peres001 at users.sourceforge.net peres001 at users.sourceforge.net
Sun Dec 9 18:31:36 CET 2007


Revision: 29799
          http://scummvm.svn.sourceforge.net/scummvm/?rev=29799&view=rev
Author:   peres001
Date:     2007-12-09 09:31:36 -0800 (Sun, 09 Dec 2007)

Log Message:
-----------
Fix for bug #1777053. Engine was ruling out valid passwords because of wrong implementation.

Modified Paths:
--------------
    scummvm/trunk/engines/parallaction/gui_ns.cpp

Modified: scummvm/trunk/engines/parallaction/gui_ns.cpp
===================================================================
--- scummvm/trunk/engines/parallaction/gui_ns.cpp	2007-12-09 17:29:41 UTC (rev 29798)
+++ scummvm/trunk/engines/parallaction/gui_ns.cpp	2007-12-09 17:31:36 UTC (rev 29799)
@@ -87,23 +87,26 @@
 
 #define PASSWORD_LEN	6
 
+#define CHAR_DINO       0
+#define CHAR_DONNA      1
+#define CHAR_DOUGH      2
 
 static const uint16 _amigaKeys[][PASSWORD_LEN] = {
-	{ 1, 3 ,7, 2, 4, 6 },		// dough
 	{ 5, 3, 6, 2, 2, 7 },		// dino
-	{ 0, 3, 6, 2, 2, 6 }		// donna
+	{ 0, 3, 6, 2, 2, 6 },		// donna
+	{ 1, 3 ,7, 2, 4, 6 }		// dough
 };
 
 static const uint16 _pcKeys[][PASSWORD_LEN] = {
-	{ 1, 7 ,7, 2, 2, 6 },		// dough
 	{ 5, 3, 6, 1, 4, 7 },		// dino
-	{ 0, 2, 8, 5, 5, 1 }		// donna
+	{ 0, 2, 8, 5, 5, 1 },		// donna
+	{ 1, 7 ,7, 2, 2, 6 }		// dough
 };
 
 static const char *_charStartLocation[] = {
-	"test.dough",
 	"test.dino",
-	"test.donna"
+	"test.donna",
+	"test.dough"
 };
 
 enum {
@@ -378,13 +381,18 @@
 
 
 	const uint16 (*keys)[PASSWORD_LEN] = (getPlatform() == Common::kPlatformAmiga && (getFeatures() & GF_LANG_MULT)) ? _amigaKeys : _pcKeys;
-	int character = -1;
 	uint16 _di = 0;
+    byte points[3] = { 0, 0, 0 };
 
-	uint16 key[PASSWORD_LEN];
+    bool fail;
 
 	while (true) {
 
+        points[0] = 0;
+        points[1] = 0;
+        points[2] = 0;
+        fail = false;
+
 		_gfx->displayString(60, 30, introMsg1[_language], 1);			// displays message
 
 		_di = 0;
@@ -397,21 +405,32 @@
 				_gfx->grabRect((byte*)v14.pixels, codeTrueBlocks[_si], Gfx::kBitFront, BLOCK_WIDTH);
 				_gfx->flatBlitCnv(&v14, _di * SLOT_WIDTH + SLOT_X, SLOT_Y, Gfx::kBitFront);
 
-				key[_di++] = _si;
-			}
-		}
+                if (keys[0][_di] == _si) {
+                    points[0]++;
+                } else
+                if (keys[1][_di] == _si) {
+                    points[1]++;
+                } else
+                if (keys[2][_di] == _si) {
+                    points[2]++;
+                } else {
+                    fail = true;
+                }
 
-		for (int i = 0; i < 3; i++) {
-			if (!memcmp(key, keys[i], sizeof(key))) {
-				character = i;
-				break;
+                // build user preference
+                points[0] += (keys[0][_di] == _si);
+                points[1] += (keys[1][_di] == _si);
+                points[2] += (keys[2][_di] == _si);
+
+                _di++;
 			}
-		}
 
-		if (character != -1) {
-			break;
 		}
 
+        if (!fail) {
+            break;
+        }
+
 		_gfx->copyScreen(Gfx::kBitBack, Gfx::kBitFront);
 		_gfx->displayString(60, 30, introMsg2[_language], 1);
 		_gfx->updateScreen();
@@ -426,8 +445,23 @@
 
 	v14.free();
 
-	return character;
 
+    // actually select character
+
+	int character = -1;
+	if (points[0] >= points[1] && points[0] >= points[2]) {
+        character = CHAR_DINO;
+	} else
+	if (points[1] >= points[0] && points[1] >= points[2]) {
+        character = CHAR_DONNA;
+	} else
+	if (points[2] >= points[0] && points[2] >= points[1]) {
+        character = CHAR_DOUGH;
+	} else {
+        error("If you read this, either your CPU or transivity is broken (we believe the former).");
+	}
+
+    return character;
 }
 
 


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