[Scummvm-cvs-logs] SF.net SVN: scummvm:[42191] scummvm/branches/gsoc2009-draci/engines/draci

dkasak13 at users.sourceforge.net dkasak13 at users.sourceforge.net
Mon Jul 6 21:26:53 CEST 2009


Revision: 42191
          http://scummvm.svn.sourceforge.net/scummvm/?rev=42191&view=rev
Author:   dkasak13
Date:     2009-07-06 19:26:53 +0000 (Mon, 06 Jul 2009)

Log Message:
-----------
Implemented Script::funcRandom (GPL function).

Modified Paths:
--------------
    scummvm/branches/gsoc2009-draci/engines/draci/script.cpp
    scummvm/branches/gsoc2009-draci/engines/draci/script.h

Modified: scummvm/branches/gsoc2009-draci/engines/draci/script.cpp
===================================================================
--- scummvm/branches/gsoc2009-draci/engines/draci/script.cpp	2009-07-06 19:22:13 UTC (rev 42190)
+++ scummvm/branches/gsoc2009-draci/engines/draci/script.cpp	2009-07-06 19:26:53 UTC (rev 42191)
@@ -117,7 +117,7 @@
 	/** 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 @@
 	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) {

Modified: scummvm/branches/gsoc2009-draci/engines/draci/script.h
===================================================================
--- scummvm/branches/gsoc2009-draci/engines/draci/script.h	2009-07-06 19:22:13 UTC (rev 42190)
+++ scummvm/branches/gsoc2009-draci/engines/draci/script.h	2009-07-06 19:26:53 UTC (rev 42191)
@@ -115,6 +115,8 @@
 	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);


This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.




More information about the Scummvm-git-logs mailing list