aboutsummaryrefslogtreecommitdiff
path: root/engines/draci
diff options
context:
space:
mode:
authorDenis Kasak2009-07-06 19:26:53 +0000
committerDenis Kasak2009-07-06 19:26:53 +0000
commitb2c24dd640eba57c1c2460a027f021118ca44920 (patch)
tree7420aa6034a98f5f1ca03e9c6b15538129eef125 /engines/draci
parent218a15d890d089e48d135533bb51f0b68043e197 (diff)
downloadscummvm-rg350-b2c24dd640eba57c1c2460a027f021118ca44920.tar.gz
scummvm-rg350-b2c24dd640eba57c1c2460a027f021118ca44920.tar.bz2
scummvm-rg350-b2c24dd640eba57c1c2460a027f021118ca44920.zip
Implemented Script::funcRandom (GPL function).
svn-id: r42191
Diffstat (limited to 'engines/draci')
-rw-r--r--engines/draci/script.cpp13
-rw-r--r--engines/draci/script.h2
2 files changed, 14 insertions, 1 deletions
diff --git a/engines/draci/script.cpp b/engines/draci/script.cpp
index 3a39f61e2d..330fc85d0a 100644
--- a/engines/draci/script.cpp
+++ b/engines/draci/script.cpp
@@ -117,7 +117,7 @@ void Script::setupCommandList() {
/** Functions used by the mathematical evaluator */
static const GPL2Function gplFunctions[] = {
{ "Not", NULL },
- { "Random", NULL },
+ { "Random", &Script::funcRandom },
{ "IsIcoOn", NULL },
{ "IsIcoAct", NULL },
{ "IcoStat", NULL },
@@ -207,6 +207,17 @@ int Script::operMod(int op1, int op2) {
return op1 % op2;
}
+/* GPL functions */
+
+int Script::funcRandom(int n) {
+
+// The function needs to return numbers in the [0..n-1] range so we need to deduce 1
+// (RandomSource::getRandomNumber returns a number in the range [0..n])
+
+ n -= 1;
+ return _vm->_rnd.getRandomNumber(n);
+}
+
/* GPL commands */
void Script::load(Common::Queue<int> &params) {
diff --git a/engines/draci/script.h b/engines/draci/script.h
index 6259f675a5..16bef9c7ff 100644
--- a/engines/draci/script.h
+++ b/engines/draci/script.h
@@ -115,6 +115,8 @@ private:
int operLessOrEqual(int op1, int op2);
int operMod(int op1, int op2);
+ int funcRandom(int n);
+
void setupCommandList();
const GPL2Command *findCommand(byte num, byte subnum);
int handleMathExpression(Common::MemoryReadStream &reader);