diff options
author | Strangerke | 2016-03-25 07:49:43 +0100 |
---|---|---|
committer | Eugene Sandulenko | 2016-05-10 09:54:21 +0200 |
commit | f3a164342b4f62c3bdf02c226880e6d2d6316a66 (patch) | |
tree | a8b7d5c49276c83ab6f67bc300ae1261f7b657ba | |
parent | ecc3e2a786629d06fbcf17e4d74605215efdc1ef (diff) | |
download | scummvm-rg350-f3a164342b4f62c3bdf02c226880e6d2d6316a66.tar.gz scummvm-rg350-f3a164342b4f62c3bdf02c226880e6d2d6316a66.tar.bz2 scummvm-rg350-f3a164342b4f62c3bdf02c226880e6d2d6316a66.zip |
GNAP: Remove a global variable used for randomization
-rw-r--r-- | engines/gnap/gnap.cpp | 25 | ||||
-rw-r--r-- | engines/gnap/gnap.h | 1 | ||||
-rw-r--r-- | engines/gnap/scenes/scene07.cpp | 2 | ||||
-rw-r--r-- | engines/gnap/scenes/scene08.cpp | 2 | ||||
-rw-r--r-- | engines/gnap/scenes/scene10.cpp | 31 | ||||
-rw-r--r-- | engines/gnap/scenes/scene11.cpp | 8 | ||||
-rw-r--r-- | engines/gnap/scenes/scene12.cpp | 5 | ||||
-rw-r--r-- | engines/gnap/scenes/scene13.cpp | 6 | ||||
-rw-r--r-- | engines/gnap/scenes/scene41.cpp | 3 | ||||
-rw-r--r-- | engines/gnap/scenes/scene42.cpp | 3 | ||||
-rw-r--r-- | engines/gnap/scenes/scene43.cpp | 3 | ||||
-rw-r--r-- | engines/gnap/scenes/scene44.cpp | 6 | ||||
-rw-r--r-- | engines/gnap/scenes/scene45.cpp | 10 | ||||
-rw-r--r-- | engines/gnap/scenes/scene46.cpp | 3 |
14 files changed, 46 insertions, 62 deletions
diff --git a/engines/gnap/gnap.cpp b/engines/gnap/gnap.cpp index 1a3bcf4f44..5077568444 100644 --- a/engines/gnap/gnap.cpp +++ b/engines/gnap/gnap.cpp @@ -1632,9 +1632,8 @@ void GnapEngine::updateGnapIdleSequence() { if (_timers[3] == 0) { _timers[2] = 60; _timers[3] = 300; - _gnapRandomValue = getRandom(5); if (_gnapIdleFacing == 1) { - switch (_gnapRandomValue) { + switch (getRandom(5)) { case 0: playGnapSequence(0x107A6); break; @@ -1649,7 +1648,7 @@ void GnapEngine::updateGnapIdleSequence() { break; } } else if (_gnapIdleFacing == 3) { - if (_gnapRandomValue > 2) + if (getRandom(5) > 2) playGnapSequence(0x10832); else playGnapSequence(0x10842); @@ -1932,19 +1931,19 @@ void GnapEngine::updateBeaverIdleSequence() { if (_timers[0] > 0) { if (_timers[1] == 0) { _timers[1] = getRandom(20) + 30; - _gnapRandomValue = getRandom(10); + int rnd = getRandom(10); if (_beaverFacing != 0) { - if (_gnapRandomValue != 0 || _beaverSequenceId != 0x7CA) { - if (_gnapRandomValue != 1 || _beaverSequenceId != 0x7CA) + if (rnd != 0 || _beaverSequenceId != 0x7CA) { + if (rnd != 1 || _beaverSequenceId != 0x7CA) playBeaverSequence(0x107CA); else playBeaverSequence(0x10845); } else { playBeaverSequence(0x107CC); } - } else if (_gnapRandomValue != 0 || _beaverSequenceId != 0x7C9) { - if (_gnapRandomValue != 1 || _beaverSequenceId != 0x7C9) { - if (_gnapRandomValue != 2 || _beaverSequenceId != 0x7C9) + } else if (rnd != 0 || _beaverSequenceId != 0x7C9) { + if (rnd != 1 || _beaverSequenceId != 0x7C9) { + if (rnd != 2 || _beaverSequenceId != 0x7C9) playBeaverSequence(0x107C9); else playBeaverSequence(0x108A4); @@ -1970,14 +1969,13 @@ void GnapEngine::beaverSub426234() { if (_timers[0]) { if (!_timers[1]) { _timers[1] = getRandom(20) + 30; - _gnapRandomValue = getRandom(10); if (_beaverFacing != 0) { - if (_gnapRandomValue >= 2 || _beaverSequenceId != 0x7CA) + if (getRandom(10) >= 2 || _beaverSequenceId != 0x7CA) playBeaverSequence(0x107CA); else playBeaverSequence(0x107CC); } else { - if (_gnapRandomValue >= 2 || _beaverSequenceId != 0x7C9) { + if (getRandom(10) >= 2 || _beaverSequenceId != 0x7C9) { playBeaverSequence(0x107C9); } else { playBeaverSequence(0x107CB); @@ -2136,8 +2134,7 @@ bool GnapEngine::sceneXX_sub_4466B1() { void GnapEngine::sceneXX_playRandomSound(int timerIndex) { if (!_timers[timerIndex]) { _timers[timerIndex] = getRandom(40) + 50; - _gnapRandomValue = getRandom(4); - switch (_gnapRandomValue) { + switch (getRandom(4)) { case 0: playSound(0x1091B, 0); break; diff --git a/engines/gnap/gnap.h b/engines/gnap/gnap.h index 5eaa25d5b5..d376ffd5c9 100644 --- a/engines/gnap/gnap.h +++ b/engines/gnap/gnap.h @@ -487,7 +487,6 @@ public: int _gnapActionStatus; int _gnapBrainPulseNum, _gnapBrainPulseRndValue; int _gnapSequenceId, _gnapSequenceDatNum, _gnapId; - int _gnapRandomValue; int getGnapSequenceId(int kind, int gridX, int gridY); int getGnapShowSequenceId(int index, int gridX, int gridY); diff --git a/engines/gnap/scenes/scene07.cpp b/engines/gnap/scenes/scene07.cpp index aa486b6fb1..c6eda8f3a1 100644 --- a/engines/gnap/scenes/scene07.cpp +++ b/engines/gnap/scenes/scene07.cpp @@ -201,7 +201,7 @@ void GnapEngine::scene07_run() { if (_timers[0]) { if (!_timers[1]) { _timers[1] = getRandom(20) + 30; - _gnapRandomValue = getRandom(20); + int _gnapRandomValue = getRandom(20); // TODO Cleanup if (_beaverFacing != 0) { if (_gnapRandomValue != 0 || _beaverSequenceId != 0x7CA) { diff --git a/engines/gnap/scenes/scene08.cpp b/engines/gnap/scenes/scene08.cpp index 29437251b6..01e77084b9 100644 --- a/engines/gnap/scenes/scene08.cpp +++ b/engines/gnap/scenes/scene08.cpp @@ -364,7 +364,7 @@ void GnapEngine::scene08_run() { _timers[4] = getRandom(50) + 125; if (_gnapActionStatus < 0 && _beaverActionStatus < 0 && _s08_nextManSequenceId == -1 && (_s08_currDogSequenceId == 0x134 || _s08_currDogSequenceId == 0x135)) { - _gnapRandomValue = getRandom(4); + int _gnapRandomValue = getRandom(4); switch (_gnapRandomValue) { case 0: _s08_nextManSequenceId = 0x138; diff --git a/engines/gnap/scenes/scene10.cpp b/engines/gnap/scenes/scene10.cpp index e2da08e3bd..aea4a34789 100644 --- a/engines/gnap/scenes/scene10.cpp +++ b/engines/gnap/scenes/scene10.cpp @@ -329,7 +329,7 @@ void GnapEngine::scene10_run() { } if (!_timers[5]) { _timers[5] = getRandom(100) + 100; - _gnapRandomValue = getRandom(4); + int _gnapRandomValue = getRandom(4); if (_gnapRandomValue) { int sequenceId; if (_gnapRandomValue == 1) { @@ -428,45 +428,46 @@ void GnapEngine::scene10_updateAnimations() { } switch (_s10_currCookSequenceId) { - case 0x106: - _gnapRandomValue = getRandom(7); + case 0x106: { + // TODO: Refactor into a if + a switch + int rnd = getRandom(7); if (_gnapActionStatus >= 0 || _beaverActionStatus >= 0) _s10_nextCookSequenceId = 0x106; - else if (_gnapRandomValue == 0) + else if (rnd == 0) _s10_nextCookSequenceId = 0x104; - else if (_gnapRandomValue == 1) + else if (rnd == 1) _s10_nextCookSequenceId = 0x103; - else if (_gnapRandomValue == 2) { + else if (rnd == 2) { _s10_nextCookSequenceId = 0x106; _gameSys->insertSequence(0x10D, 1, 0, 0, kSeqNone, 0, 0, 0); } else _s10_nextCookSequenceId = 0x106; + } break; case 0x103: - _gnapRandomValue = getRandom(7); if (_gnapActionStatus >= 0 || _beaverActionStatus >= 0) _s10_nextCookSequenceId = 0x106; - else if (_gnapRandomValue == 0) + else if (getRandom(7) == 0) _s10_nextCookSequenceId = 0x104; else _s10_nextCookSequenceId = 0x106; break; case 0x104: - _gnapRandomValue = getRandom(7); if (_gnapActionStatus >= 0 || _beaverActionStatus >= 0) _s10_nextCookSequenceId = 0x106; - else if (_gnapRandomValue == 0) + else if (getRandom(7) == 0) _s10_nextCookSequenceId = 0x103; else _s10_nextCookSequenceId = 0x106; break; - case 0x105: - _gnapRandomValue = getRandom(7); + case 0x105: { + // TODO: Refactor into a if + a switch + int rnd = getRandom(7); if (_gnapActionStatus >= 0 || _beaverActionStatus >= 0) _s10_nextCookSequenceId = 0x106; - else if (_gnapRandomValue == 0) + else if (rnd == 0) _s10_nextCookSequenceId = 0x104; - else if (_gnapRandomValue == 1) + else if (rnd == 1) _s10_nextCookSequenceId = 0x103; else _s10_nextCookSequenceId = 0x106; @@ -478,6 +479,7 @@ void GnapEngine::scene10_updateAnimations() { _gnapSequenceDatNum = 0; _gnapActionStatus = -1; _beaverActionStatus = -1; + } break; } if (_s10_currCookSequenceId == 0x843) @@ -485,7 +487,6 @@ void GnapEngine::scene10_updateAnimations() { else _gameSys->setAnimation(_s10_currCookSequenceId, 100, 2); } - } void GnapEngine::scene10_updateAnimationsCb() { diff --git a/engines/gnap/scenes/scene11.cpp b/engines/gnap/scenes/scene11.cpp index 8097b23e73..04509eef5c 100644 --- a/engines/gnap/scenes/scene11.cpp +++ b/engines/gnap/scenes/scene11.cpp @@ -311,8 +311,7 @@ void GnapEngine::scene11_run() { if (!_timers[5]) { _timers[5] = getRandom(100) + 75; if (_gnapActionStatus < 0 && _beaverActionStatus < 0 && _s11_nextGoggleGuySequenceId == -1) { - _gnapRandomValue = getRandom(2); - if (_gnapRandomValue) + if (getRandom(2)) _s11_nextGoggleGuySequenceId = 0x1F6; else _s11_nextGoggleGuySequenceId = 0x1F9; @@ -322,8 +321,7 @@ void GnapEngine::scene11_run() { _timers[4] = getRandom(40) + 20; if (_gnapActionStatus < 0 && _beaverActionStatus < 0 && _s11_nextHookGuySequenceId == -1) { if (_s11_currHookGuySequenceId == 0x201) { - _gnapRandomValue = getRandom(7); - switch (_gnapRandomValue) { + switch (getRandom(7)) { case 0: _s11_nextHookGuySequenceId = 0x200; break; @@ -344,7 +342,7 @@ void GnapEngine::scene11_run() { } if (!_timers[6]) { _timers[6] = getRandom(100) + 100; - _gnapRandomValue = getRandom(3); + int _gnapRandomValue = getRandom(3); switch (_gnapRandomValue) { case 0: _gameSys->insertSequence(0x8A5 | 0x10000, 179, 0, 0, kSeqNone, 0, 0, 0); diff --git a/engines/gnap/scenes/scene12.cpp b/engines/gnap/scenes/scene12.cpp index 4bc10fcb43..f26bb30f0b 100644 --- a/engines/gnap/scenes/scene12.cpp +++ b/engines/gnap/scenes/scene12.cpp @@ -347,7 +347,7 @@ void GnapEngine::scene12_run() { } if (!_timers[7]) { _timers[7] = getRandom(100) + 100; - _gnapRandomValue = getRandom(3); + int _gnapRandomValue = getRandom(3); switch (_gnapRandomValue) { case 0: _gameSys->insertSequence(0x8A5 | 0x10000, 179, 0, 0, kSeqNone, 0, 0, 0); @@ -450,8 +450,7 @@ void GnapEngine::scene12_updateAnimations() { _s12_nextBeardGuySequenceId = 0x1F0; break; case kASTalkBarkeeper: - _gnapRandomValue = getRandom(2); - if (_gnapRandomValue != 0) + if (getRandom(2) != 0) _s12_nextBarkeeperSequenceId = 0x1FD; else _s12_nextBarkeeperSequenceId = 0x1FF; diff --git a/engines/gnap/scenes/scene13.cpp b/engines/gnap/scenes/scene13.cpp index 2897f687db..4d7b6d01c6 100644 --- a/engines/gnap/scenes/scene13.cpp +++ b/engines/gnap/scenes/scene13.cpp @@ -324,8 +324,7 @@ void GnapEngine::scene13_run() { updateGnapIdleSequence(); if (!_timers[4]) { _timers[4] = getRandom(20) + 20; - _gnapRandomValue = getRandom(5); - switch (_gnapRandomValue) { + switch (getRandom(5)) { case 0: playSound(0xD2, 0); break; @@ -346,8 +345,7 @@ void GnapEngine::scene13_run() { if (!_timers[5]) { int newSoundId; _timers[5] = getRandom(50) + 50; - _gnapRandomValue = getRandom(7); - switch (_gnapRandomValue) { + switch (getRandom(7)) { case 0: newSoundId = 0xD7; _timers[5] = 2 * getRandom(50) + 100; diff --git a/engines/gnap/scenes/scene41.cpp b/engines/gnap/scenes/scene41.cpp index b84c4ba988..ca5c677264 100644 --- a/engines/gnap/scenes/scene41.cpp +++ b/engines/gnap/scenes/scene41.cpp @@ -394,8 +394,7 @@ void GnapEngine::scene41_run() { if (!_timers[4]) { _timers[4] = getRandom(100) + 100; if (_gnapActionStatus < 0 && _beaverActionStatus < 0 && _toyUfoActionStatus == -1 && _s41_nextToyVendorSequenceId == -1) { - _gnapRandomValue = getRandom(3); - switch (_gnapRandomValue) { + switch (getRandom(3)) { case 0: _s41_nextToyVendorSequenceId = 0x113; break; diff --git a/engines/gnap/scenes/scene42.cpp b/engines/gnap/scenes/scene42.cpp index 8de3a694eb..3826f7b29b 100644 --- a/engines/gnap/scenes/scene42.cpp +++ b/engines/gnap/scenes/scene42.cpp @@ -330,8 +330,7 @@ void GnapEngine::scene42_run() { if (!_timers[4]) { _timers[4] = getRandom(20) + 30; if (_gnapActionStatus < 0 && _beaverActionStatus < 0 && _s42_nextBBQVendorSequenceId == -1) { - _gnapRandomValue = getRandom(8); - switch (_gnapRandomValue) { + switch (getRandom(8)) { case 0: _s42_nextBBQVendorSequenceId = 0x14C; break; diff --git a/engines/gnap/scenes/scene43.cpp b/engines/gnap/scenes/scene43.cpp index 51917d5389..957aea3ec6 100644 --- a/engines/gnap/scenes/scene43.cpp +++ b/engines/gnap/scenes/scene43.cpp @@ -333,8 +333,7 @@ void GnapEngine::scene43_run() { if (!_timers[4] && (!isFlag(12) || !isFlag(19))) { _timers[4] = getRandom(100) + 100; if (_gnapActionStatus < 0 && _beaverActionStatus < 0 && _s43_nextTwoHeadedGuySequenceId == -1) { - _gnapRandomValue = getRandom(5); - switch (_gnapRandomValue) { + switch (getRandom(5)) { case 0: _s43_nextTwoHeadedGuySequenceId = 0x13C; break; diff --git a/engines/gnap/scenes/scene44.cpp b/engines/gnap/scenes/scene44.cpp index c0905c7434..3bcde76fc6 100644 --- a/engines/gnap/scenes/scene44.cpp +++ b/engines/gnap/scenes/scene44.cpp @@ -376,8 +376,7 @@ void GnapEngine::scene44_run() { if (!_timers[4]) { _timers[4] = getRandom(20) + 20; if (_gnapActionStatus < 0 && _beaverActionStatus < 0 && _s44_nextKissingLadySequenceId == -1) { - _gnapRandomValue = getRandom(20); - switch (_gnapRandomValue) { + switch (getRandom(20)) { case 0: _s44_nextKissingLadySequenceId = 0xED; break; @@ -404,8 +403,7 @@ void GnapEngine::scene44_run() { if (!_timers[5]) { _timers[5] = getRandom(20) + 20; if (_gnapActionStatus < 0 && _beaverActionStatus < 0 && _s44_nextSpringGuySequenceId == -1) { - _gnapRandomValue = getRandom(5); - if (_gnapRandomValue != 0) { + if (getRandom(5) != 0) { if (!isFlag(15)) _s44_nextSpringGuySequenceId = 0xF9; } else { diff --git a/engines/gnap/scenes/scene45.cpp b/engines/gnap/scenes/scene45.cpp index b25216d5bf..87d52bef4b 100644 --- a/engines/gnap/scenes/scene45.cpp +++ b/engines/gnap/scenes/scene45.cpp @@ -147,9 +147,8 @@ void GnapEngine::scene45_run() { gameUpdateTick(); if (_gameSys->getAnimationStatus(2) == 2) { _gameSys->setAnimation(0, 0, 2); - _gnapRandomValue = getRandom(7); - int newSeqId = _gnapRandomValue + 0x8F; - _gameSys->insertSequence(_gnapRandomValue + 0x8F, 1, _s45_currDancerSequenceId, 1, kSeqSyncWait, 0, 0, 0); + int newSeqId = getRandom(7) + 0x8F; + _gameSys->insertSequence(newSeqId, 1, _s45_currDancerSequenceId, 1, kSeqSyncWait, 0, 0, 0); _gameSys->setAnimation(newSeqId, 1, 2); _s45_currDancerSequenceId = newSeqId; } @@ -393,9 +392,8 @@ void GnapEngine::scene45_updateAnimations() { if (_gameSys->getAnimationStatus(2) == 2) { _gameSys->setAnimation(0, 0, 2); - _gnapRandomValue = getRandom(7); - int newSeqId = _gnapRandomValue + 0x8F; - _gameSys->insertSequence(_gnapRandomValue + 0x8F, 1, _s45_currDancerSequenceId, 1, kSeqSyncWait, 0, 0, 0); + int newSeqId = getRandom(7) + 0x8F; + _gameSys->insertSequence(newSeqId + 0x8F, 1, _s45_currDancerSequenceId, 1, kSeqSyncWait, 0, 0, 0); _gameSys->setAnimation(newSeqId, 1, 2); _s45_currDancerSequenceId = newSeqId; } diff --git a/engines/gnap/scenes/scene46.cpp b/engines/gnap/scenes/scene46.cpp index 864f3418d4..544829207e 100644 --- a/engines/gnap/scenes/scene46.cpp +++ b/engines/gnap/scenes/scene46.cpp @@ -288,8 +288,7 @@ void GnapEngine::scene46_run() { if (!_timers[4]) { _timers[4] = getRandom(50) + 80; if (_gnapActionStatus < 0 && _beaverActionStatus < 0 && _s46_nextItchyGuySequenceId == -1) { - _gnapRandomValue = getRandom(2); - if (_gnapRandomValue != 0) + if (getRandom(2) != 0) _s46_nextItchyGuySequenceId = 0x49; else _s46_nextItchyGuySequenceId = 0x48; |