aboutsummaryrefslogtreecommitdiff
path: root/engines/agi
diff options
context:
space:
mode:
authorFilippos Karapetis2007-09-21 19:35:26 +0000
committerFilippos Karapetis2007-09-21 19:35:26 +0000
commit2310d1f62a1f1124b493d9d7d6a3a3574217b5e6 (patch)
treec4976715322f175e58bf7d4b98bbc08ca513bbc9 /engines/agi
parentdc4c06e954ee0d09f8227e6cf3bf4f083a43eedf (diff)
downloadscummvm-rg350-2310d1f62a1f1124b493d9d7d6a3a3574217b5e6.tar.gz
scummvm-rg350-2310d1f62a1f1124b493d9d7d6a3a3574217b5e6.tar.bz2
scummvm-rg350-2310d1f62a1f1124b493d9d7d6a3a3574217b5e6.zip
Simplified Mickey::randomize()
svn-id: r29008
Diffstat (limited to 'engines/agi')
-rw-r--r--engines/agi/preagi_mickey.cpp22
-rw-r--r--engines/agi/preagi_mickey.h9
2 files changed, 13 insertions, 18 deletions
diff --git a/engines/agi/preagi_mickey.cpp b/engines/agi/preagi_mickey.cpp
index 264c0ac8b0..056e556f58 100644
--- a/engines/agi/preagi_mickey.cpp
+++ b/engines/agi/preagi_mickey.cpp
@@ -1255,7 +1255,6 @@ void Mickey::inventory() {
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 @@ void Mickey::randomize() {
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;
diff --git a/engines/agi/preagi_mickey.h b/engines/agi/preagi_mickey.h
index 24a07d376e..fe0b647915 100644
--- a/engines/agi/preagi_mickey.h
+++ b/engines/agi/preagi_mickey.h
@@ -732,7 +732,6 @@ struct MSA_GAME {
class Mickey {
friend class PreAgiEngine;
public:
-
Mickey(PreAgiEngine *vm);
~Mickey();
@@ -803,6 +802,14 @@ protected:
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