MADS: Introduce another getRandomNumber function with 2 parameters
This commit is contained in:
parent
eb82e63398
commit
c42e831817
5 changed files with 12 additions and 5 deletions
|
@ -107,6 +107,12 @@ int MADSEngine::getRandomNumber(int maxNumber) {
|
||||||
return _randomSource.getRandomNumber(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) {
|
int MADSEngine::hypotenuse(int xv, int yv) {
|
||||||
return (int)sqrt((double)(xv * xv + yv * yv));
|
return (int)sqrt((double)(xv * xv + yv * yv));
|
||||||
}
|
}
|
||||||
|
|
|
@ -116,6 +116,7 @@ public:
|
||||||
uint32 getGameFeatures() const;
|
uint32 getGameFeatures() const;
|
||||||
|
|
||||||
int getRandomNumber(int maxNumber);
|
int getRandomNumber(int maxNumber);
|
||||||
|
int getRandomNumber(int minNumber, int maxNumber);
|
||||||
int hypotenuse(int xv, int yv);
|
int hypotenuse(int xv, int yv);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -90,7 +90,7 @@ bool CopyProtectionDialog::getHogAnusEntry(HOGANUS &entry) {
|
||||||
|
|
||||||
// Read in the total number of entries, and randomly pick an entry to use
|
// Read in the total number of entries, and randomly pick an entry to use
|
||||||
int numEntries = f.readUint16LE();
|
int numEntries = f.readUint16LE();
|
||||||
int entryIndex = _vm->getRandomNumber(numEntries - 2) + 1;
|
int entryIndex = _vm->getRandomNumber(1, numEntries);
|
||||||
|
|
||||||
// Read in the encrypted entry
|
// Read in the encrypted entry
|
||||||
f.seek(28 * entryIndex + 2);
|
f.seek(28 * entryIndex + 2);
|
||||||
|
|
|
@ -462,7 +462,7 @@ void Scene202::enter() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void Scene202::setRandomKernelMessage() {
|
void Scene202::setRandomKernelMessage() {
|
||||||
int vocabId = 92 + _vm->getRandomNumber(4);
|
int vocabId = _vm->getRandomNumber(92, 96);
|
||||||
_scene->_kernelMessages.reset();
|
_scene->_kernelMessages.reset();
|
||||||
_game._abortTimersMode2 = ABORTMODE_1;
|
_game._abortTimersMode2 = ABORTMODE_1;
|
||||||
_scene->_kernelMessages.add(Common::Point(0, 0), 0x1110, 34, 70, 120, _game.getQuote(vocabId));
|
_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)) {
|
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;
|
int threshold = 1;
|
||||||
if (_globals._v4)
|
if (_globals._v4)
|
||||||
threshold = 26;
|
threshold = 26;
|
||||||
|
@ -614,7 +614,7 @@ void Scene202::step() {
|
||||||
// }
|
// }
|
||||||
|
|
||||||
warning("TODO: word84260 = _scene->_activeAnimation->getCurrentFrame();");
|
warning("TODO: word84260 = _scene->_activeAnimation->getCurrentFrame();");
|
||||||
int randVal = _vm->getRandomNumber(999) + 1;
|
int randVal = _vm->getRandomNumber(1, 1000);
|
||||||
int frameStep = -1;
|
int frameStep = -1;
|
||||||
|
|
||||||
switch (_scene->_activeAnimation->getCurrentFrame()) {
|
switch (_scene->_activeAnimation->getCurrentFrame()) {
|
||||||
|
|
|
@ -239,7 +239,7 @@ void Scene804::step() {
|
||||||
|
|
||||||
switch (_scene->_activeAnimation->getCurrentFrame()) {
|
switch (_scene->_activeAnimation->getCurrentFrame()) {
|
||||||
case 1:
|
case 1:
|
||||||
_globals[29] = _vm->getRandomNumber(29) + 1;
|
_globals[29] = _vm->getRandomNumber(1, 30);
|
||||||
switch (_globals[29]) {
|
switch (_globals[29]) {
|
||||||
case 1:
|
case 1:
|
||||||
_globals._v5 = 25;
|
_globals._v5 = 25;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue