[Scummvm-cvs-logs] CVS: scummvm/scumm script_v6.cpp,1.72,1.73

Max Horn fingolfin at users.sourceforge.net
Fri Mar 7 13:50:02 CET 2003


Update of /cvsroot/scummvm/scummvm/scumm
In directory sc8-pr-cvs1:/tmp/cvs-serv1768

Modified Files:
	script_v6.cpp 
Log Message:
replaced shuffleArray with a meaningful implementation, even if it differes from assembly

Index: script_v6.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/scumm/script_v6.cpp,v
retrieving revision 1.72
retrieving revision 1.73
diff -u -d -r1.72 -r1.73
--- script_v6.cpp	7 Mar 2003 21:38:45 -0000	1.72
+++ script_v6.cpp	7 Mar 2003 21:49:06 -0000	1.73
@@ -2812,16 +2812,17 @@
 	int range = maxIdx - minIdx;
 	int count = range * 2;
 
+	// Shuffle the array 'num'
 	while (count--) {
+		// Determine two random elements...
 		int rand1 = _rnd.getRandomNumber(range) + minIdx;
 		int rand2 = _rnd.getRandomNumber(range) + minIdx;
-		_vars[VAR_V6_RANDOM_NR] = rand2;
 		
-		// FIXME - uhm this seems wrong. It replaces item rand1 with itself
-		// It would seem more logical if we first read elements rand1 and rand2,
-		// then swapped them. Assembler analysis, anybody?
-		writeArray(num, 0, rand1, readArray(num, 0, rand1));
-		writeArray(num, 0, rand2, readArray(num, 0, rand2));
+		// ...and swap them
+		int val1 = readArray(num, 0, rand1);
+		int val2 = readArray(num, 0, rand2);
+		writeArray(num, 0, rand1, val2);
+		writeArray(num, 0, rand2, val1));
 	}
 }
 





More information about the Scummvm-git-logs mailing list