diff options
-rw-r--r-- | engines/sci/engine/kmath.cpp | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/engines/sci/engine/kmath.cpp b/engines/sci/engine/kmath.cpp index ea427435f2..53191180a2 100644 --- a/engines/sci/engine/kmath.cpp +++ b/engines/sci/engine/kmath.cpp @@ -29,7 +29,10 @@ namespace Sci { reg_t kRandom(EngineState *s, int argc, reg_t *argv) { - return make_reg(0, argv[0].toSint16() + (int)((argv[1].toSint16() + 1.0 - argv[0].toSint16()) * (rand() / (RAND_MAX + 1.0)))); + int fromNumber = argv[0].toUint16(); + int toNumber = argv[1].toUint16(); + int randomNumber = fromNumber + ((toNumber + 1.0 - fromNumber) * (rand() / (RAND_MAX + 1.0))); + return make_reg(0, randomNumber); } reg_t kAbs(EngineState *s, int argc, reg_t *argv) { |