diff options
author | Filippos Karapetis | 2011-09-23 00:21:49 +0300 |
---|---|---|
committer | Filippos Karapetis | 2011-09-23 00:22:44 +0300 |
commit | 0b4802c24b35af7dd233a6f06b77ef72cb684a54 (patch) | |
tree | e51bd75a9304bbe48b13c254eda5961fa8c724bd | |
parent | 3542dc2c44cf3f404b6cd1eb4b4f800a192b04ad (diff) | |
download | scummvm-rg350-0b4802c24b35af7dd233a6f06b77ef72cb684a54.tar.gz scummvm-rg350-0b4802c24b35af7dd233a6f06b77ef72cb684a54.tar.bz2 scummvm-rg350-0b4802c24b35af7dd233a6f06b77ef72cb684a54.zip |
SCI: Fixed bug #3413020 - "SCI: Longbow: Robin is stuck in the final monk chase scene"
Special thanks to wjp for his work on bisecting to find the regression and
for checking against the KQ5CD disasm
-rw-r--r-- | engines/sci/engine/kmath.cpp | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/engines/sci/engine/kmath.cpp b/engines/sci/engine/kmath.cpp index ef795d7e2f..7570856dff 100644 --- a/engines/sci/engine/kmath.cpp +++ b/engines/sci/engine/kmath.cpp @@ -37,6 +37,14 @@ reg_t kRandom(EngineState *s, int argc, reg_t *argv) { // some codes in sq4 are also random and 5 digit (if i remember correctly) const uint16 fromNumber = argv[0].toUint16(); const uint16 toNumber = argv[1].toUint16(); + // Some scripts may request a range in the reverse order (from largest + // to smallest). An example can be found in Longbow, room 710, where a + // random number is requested from 119 to 83. In this case, we're + // supposed to return toNumber (determined by the KQ5CD disasm). + // Fixes bug #3413020. + if (fromNumber > toNumber) + return make_reg(0, toNumber); + uint16 range = toNumber - fromNumber + 1; // calculating range is exactly how sierra sci did it and is required for hoyle 4 // where we get called with kRandom(0, -1) and we are supposed to give back values from 0 to 0 |