aboutsummaryrefslogtreecommitdiff
path: root/engines
diff options
context:
space:
mode:
authorMartin Kiewitz2009-10-19 19:38:42 +0000
committerMartin Kiewitz2009-10-19 19:38:42 +0000
commitbf4cf09eeca19a3bf614060d9e3b71d8e210b0c4 (patch)
treef36ff27d1ae81aa1e319ccce4cdca8b31f25a956 /engines
parent86c8bb6bbfcc4422ebc6a1b2ba8b26485c1026d6 (diff)
downloadscummvm-rg350-bf4cf09eeca19a3bf614060d9e3b71d8e210b0c4.tar.gz
scummvm-rg350-bf4cf09eeca19a3bf614060d9e3b71d8e210b0c4.tar.bz2
scummvm-rg350-bf4cf09eeca19a3bf614060d9e3b71d8e210b0c4.zip
SCI: kRandom behaviour fixed, fixes lsl5 patty random door code
svn-id: r45250
Diffstat (limited to 'engines')
-rw-r--r--engines/sci/engine/kmath.cpp5
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) {