[Scummvm-cvs-logs] SF.net SVN: scummvm: [29008] scummvm/trunk/engines/agi

thebluegr at users.sourceforge.net thebluegr at users.sourceforge.net
Fri Sep 21 21:35:27 CEST 2007


Revision: 29008
          http://scummvm.svn.sourceforge.net/scummvm/?rev=29008&view=rev
Author:   thebluegr
Date:     2007-09-21 12:35:26 -0700 (Fri, 21 Sep 2007)

Log Message:
-----------
Simplified Mickey::randomize()

Modified Paths:
--------------
    scummvm/trunk/engines/agi/preagi_mickey.cpp
    scummvm/trunk/engines/agi/preagi_mickey.h

Modified: scummvm/trunk/engines/agi/preagi_mickey.cpp
===================================================================
--- scummvm/trunk/engines/agi/preagi_mickey.cpp	2007-09-21 19:12:53 UTC (rev 29007)
+++ scummvm/trunk/engines/agi/preagi_mickey.cpp	2007-09-21 19:35:26 UTC (rev 29008)
@@ -1255,7 +1255,6 @@
 void Mickey::randomize() {
 	int iPlanet = 0;
 	int iHint = 0;
-	bool done;
 
 	memset(game.iPlanetXtal, 0, sizeof(game.iPlanetXtal));
 	memset(game.iClue, 0, sizeof(game.iClue));
@@ -1263,22 +1262,11 @@
 	game.iPlanetXtal[0] = IDI_MSA_PLANET_EARTH;
 	game.iPlanetXtal[8] = IDI_MSA_PLANET_URANUS;
 
-	for (int i = 1; i < 9; i++) {
-		if (i == 8) {
-			iPlanet = IDI_MSA_PLANET_URANUS;
-		} else {
-			done = false;
-			while (!done) {
-				iPlanet = _vm->rnd(IDI_MSA_MAX_PLANET - 2);	// Earth (planet 0) is excluded
-				done = true;
-				for (int j = 0; j < IDI_MSA_MAX_PLANET; j++) {
-					if (game.iPlanetXtal[j] == iPlanet) {
-						done = false;
-						break;
-					}
-				}
-			}
-		}
+	for (int i = 1; i < 8; i++) {
+		do {
+			// Earth (planet 0) and Uranus (planet 8) are excluded
+			iPlanet = _vm->rnd(IDI_MSA_MAX_PLANET - 2);
+		} while (planetIsAlreadyAssigned(iPlanet));
 
 		game.iPlanetXtal[i] = iPlanet;
 

Modified: scummvm/trunk/engines/agi/preagi_mickey.h
===================================================================
--- scummvm/trunk/engines/agi/preagi_mickey.h	2007-09-21 19:12:53 UTC (rev 29007)
+++ scummvm/trunk/engines/agi/preagi_mickey.h	2007-09-21 19:35:26 UTC (rev 29008)
@@ -732,7 +732,6 @@
 class Mickey {
 	friend class PreAgiEngine;
 public:
-
 	Mickey(PreAgiEngine *vm);
 	~Mickey();
 
@@ -803,6 +802,14 @@
 	void flipSwitch();
 	void waitAnyKeyAnim();
 	void waitAnyKey(bool anim = false);
+
+	bool planetIsAlreadyAssigned(int planet) {
+		for (int j = 0; j < IDI_MSA_MAX_PLANET; j++) {
+			if (game.iPlanetXtal[j] == planet)
+				return true;
+		}
+		return false;
+	}
 };
 
 } // End of namespace Agi


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