diff options
Diffstat (limited to 'engines/agi')
-rw-r--r-- | engines/agi/preagi_mickey.cpp | 22 | ||||
-rw-r--r-- | engines/agi/preagi_mickey.h | 9 |
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 |