mirror of
https://github.com/libretro/scummvm.git
synced 2025-01-18 16:03:05 +00:00
Implemented Script::funcRandom (GPL function).
svn-id: r42191
This commit is contained in:
parent
218a15d890
commit
b2c24dd640
@ -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> ¶ms) {
|
||||
|
@ -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);
|
||||
|
Loading…
x
Reference in New Issue
Block a user