diff options
author | Strangerke | 2014-03-22 22:02:52 +0100 |
---|---|---|
committer | Strangerke | 2014-03-22 22:02:52 +0100 |
commit | c42e831817d3eef04f493c08cd288dfe41f764e6 (patch) | |
tree | f71cb1857708f23b250a1bc98e4a876d603607de | |
parent | eb82e63398c2050cbb72008cd849b8d1fda89c3e (diff) | |
download | scummvm-rg350-c42e831817d3eef04f493c08cd288dfe41f764e6.tar.gz scummvm-rg350-c42e831817d3eef04f493c08cd288dfe41f764e6.tar.bz2 scummvm-rg350-c42e831817d3eef04f493c08cd288dfe41f764e6.zip |
MADS: Introduce another getRandomNumber function with 2 parameters
-rw-r--r-- | engines/mads/mads.cpp | 6 | ||||
-rw-r--r-- | engines/mads/mads.h | 1 | ||||
-rw-r--r-- | engines/mads/nebular/dialogs_nebular.cpp | 2 | ||||
-rw-r--r-- | engines/mads/nebular/nebular_scenes2.cpp | 6 | ||||
-rw-r--r-- | engines/mads/nebular/nebular_scenes8.cpp | 2 |
5 files changed, 12 insertions, 5 deletions
diff --git a/engines/mads/mads.cpp b/engines/mads/mads.cpp index d6cd901a4c..68d8579dc4 100644 --- a/engines/mads/mads.cpp +++ b/engines/mads/mads.cpp @@ -107,6 +107,12 @@ int MADSEngine::getRandomNumber(int maxNumber) { return _randomSource.getRandomNumber(maxNumber); } +int MADSEngine::getRandomNumber(int minNumber, int maxNumber) { + int range = maxNumber - minNumber; + + return minNumber + _randomSource.getRandomNumber(range); +} + int MADSEngine::hypotenuse(int xv, int yv) { return (int)sqrt((double)(xv * xv + yv * yv)); } diff --git a/engines/mads/mads.h b/engines/mads/mads.h index e9da307bbf..cf8046f8f6 100644 --- a/engines/mads/mads.h +++ b/engines/mads/mads.h @@ -116,6 +116,7 @@ public: uint32 getGameFeatures() const; int getRandomNumber(int maxNumber); + int getRandomNumber(int minNumber, int maxNumber); int hypotenuse(int xv, int yv); }; diff --git a/engines/mads/nebular/dialogs_nebular.cpp b/engines/mads/nebular/dialogs_nebular.cpp index dc74f39fe8..6dabbec1b9 100644 --- a/engines/mads/nebular/dialogs_nebular.cpp +++ b/engines/mads/nebular/dialogs_nebular.cpp @@ -90,7 +90,7 @@ bool CopyProtectionDialog::getHogAnusEntry(HOGANUS &entry) { // Read in the total number of entries, and randomly pick an entry to use int numEntries = f.readUint16LE(); - int entryIndex = _vm->getRandomNumber(numEntries - 2) + 1; + int entryIndex = _vm->getRandomNumber(1, numEntries); // Read in the encrypted entry f.seek(28 * entryIndex + 2); diff --git a/engines/mads/nebular/nebular_scenes2.cpp b/engines/mads/nebular/nebular_scenes2.cpp index 4acbe92475..cc896c6015 100644 --- a/engines/mads/nebular/nebular_scenes2.cpp +++ b/engines/mads/nebular/nebular_scenes2.cpp @@ -462,7 +462,7 @@ void Scene202::enter() { } void Scene202::setRandomKernelMessage() { - int vocabId = 92 + _vm->getRandomNumber(4); + int vocabId = _vm->getRandomNumber(92, 96); _scene->_kernelMessages.reset(); _game._abortTimersMode2 = ABORTMODE_1; _scene->_kernelMessages.add(Common::Point(0, 0), 0x1110, 34, 70, 120, _game.getQuote(vocabId)); @@ -555,7 +555,7 @@ void Scene202::step() { } if (!_scene->_activeAnimation && (_globals[33] != 2) && (_globals._v7 <= _scene->_frameStartTime) && (_game._scene._v8425C <= _scene->_frameStartTime)) { - int randVal = _vm->getRandomNumber(499) + 1; + int randVal = _vm->getRandomNumber(1, 500); int threshold = 1; if (_globals._v4) threshold = 26; @@ -614,7 +614,7 @@ void Scene202::step() { // } warning("TODO: word84260 = _scene->_activeAnimation->getCurrentFrame();"); - int randVal = _vm->getRandomNumber(999) + 1; + int randVal = _vm->getRandomNumber(1, 1000); int frameStep = -1; switch (_scene->_activeAnimation->getCurrentFrame()) { diff --git a/engines/mads/nebular/nebular_scenes8.cpp b/engines/mads/nebular/nebular_scenes8.cpp index dd86b56a65..2a28edee1d 100644 --- a/engines/mads/nebular/nebular_scenes8.cpp +++ b/engines/mads/nebular/nebular_scenes8.cpp @@ -239,7 +239,7 @@ void Scene804::step() { switch (_scene->_activeAnimation->getCurrentFrame()) { case 1: - _globals[29] = _vm->getRandomNumber(29) + 1; + _globals[29] = _vm->getRandomNumber(1, 30); switch (_globals[29]) { case 1: _globals._v5 = 25; |