Skip to content

Commit

Permalink
SCI: Fixed bug #3413020 - "SCI: Longbow: Robin is stuck in the final …
Browse files Browse the repository at this point in the history
…monk chase scene"

Special thanks to wjp for his work on bisecting to find the regression and
for checking against the KQ5CD disasm
  • Loading branch information
bluegr committed Sep 22, 2011
1 parent 3542dc2 commit 0b4802c
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions engines/sci/engine/kmath.cpp
Expand Up @@ -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
Expand Down

1 comment on commit 0b4802c

@bluegr
Copy link
Member Author

@bluegr bluegr commented on 0b4802c Sep 22, 2011

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A regression from 1b9d95e (kRandom rewrite)

Please sign in to comment.