diff options
author | Eugene Sandulenko | 2016-02-16 10:57:04 +0100 |
---|---|---|
committer | Eugene Sandulenko | 2016-02-16 11:32:47 +0100 |
commit | 2ccbfd2ede60d343d5481692b83da4aeb7723a16 (patch) | |
tree | f7d2698db1bbe8f555887d9bbd68bd09c97ac562 /engines/wage | |
parent | b31990246ee1b5c60dbca24cc9539d372a195aba (diff) | |
download | scummvm-rg350-2ccbfd2ede60d343d5481692b83da4aeb7723a16.tar.gz scummvm-rg350-2ccbfd2ede60d343d5481692b83da4aeb7723a16.tar.bz2 scummvm-rg350-2ccbfd2ede60d343d5481692b83da4aeb7723a16.zip |
WAGE: Fix random direction choosing logic
Diffstat (limited to 'engines/wage')
-rw-r--r-- | engines/wage/combat.cpp | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/engines/wage/combat.cpp b/engines/wage/combat.cpp index aa8ec535d2..4f2956d7d2 100644 --- a/engines/wage/combat.cpp +++ b/engines/wage/combat.cpp @@ -402,20 +402,22 @@ void WageEngine::performMove(Chr *chr, int validMoves) { // count how many valid moves we have int numValidMoves = 0; - for (int dir = 0; dir < 4; dir++) - if ((validMoves & (1 << dir)) != 0) + for (int i = 0; i < 4; i++) + if ((validMoves & (1 << i)) != 0) numValidMoves++; // Now pick random dir - int dir = _rnd->getRandomNumber(numValidMoves); + int dirNum = _rnd->getRandomNumber(numValidMoves - 1); + int dir = 0; // And get it - for (int i = 0; i < 4; i++, dir--) + for (int i = 0; i < 4; i++) if ((validMoves & (1 << i)) != 0) { - if (dir == 1) { + if (dirNum == 0) { dir = i; break; } + dirNum--; } char buf[256]; |