[Scummvm-cvs-logs] CVS: scummvm/bs2 anims.cpp,1.27,1.28 function.cpp,1.24,1.25 sound.cpp,1.24,1.25 sword2.h,1.17,1.18

Torbj?rn Andersson eriktorbjorn at users.sourceforge.net
Wed Oct 8 11:04:04 CEST 2003


Update of /cvsroot/scummvm/scummvm/bs2
In directory sc8-pr-cvs1:/tmp/cvs-serv10210

Modified Files:
	anims.cpp function.cpp sound.cpp sword2.h 
Log Message:
Use RandomSource instead of rand().


Index: anims.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/bs2/anims.cpp,v
retrieving revision 1.27
retrieving revision 1.28
diff -u -d -r1.27 -r1.28
--- anims.cpp	6 Oct 2003 07:32:54 -0000	1.27
+++ anims.cpp	8 Oct 2003 18:02:52 -0000	1.28
@@ -24,7 +24,7 @@
 // ---------------------------------------------------------------------------
 
 #include "stdafx.h"
-#include "common/scummsys.h"
+#include "bs2/sword2.h"
 #include "bs2/driver/driver96.h"
 #include "bs2/driver/d_draw.h"
 #include "bs2/anims.h"

Index: function.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/bs2/function.cpp,v
retrieving revision 1.24
retrieving revision 1.25
diff -u -d -r1.24 -r1.25
--- function.cpp	7 Oct 2003 07:07:46 -0000	1.24
+++ function.cpp	8 Oct 2003 18:02:53 -0000	1.25
@@ -135,11 +135,11 @@
 	// Generates a random number between 'min' & 'max' inclusive, and
 	// sticks it in the script flag 'result'
 
-	uint32 min = params[0];
-	uint32 max = params[1];
+	// params:	0 min
+	//		1 max
 
 	// return_value = random integer between min and max, inclusive
-	RESULT = (rand() % (max-min + 1)) + min;
+	RESULT = g_sword2->_rnd.getRandomNumberRng(params[0], params[1]);
 	
 	// continue script
 	return IR_CONT;

Index: sound.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/bs2/sound.cpp,v
retrieving revision 1.24
retrieving revision 1.25
diff -u -d -r1.24 -r1.25
--- sound.cpp	5 Oct 2003 15:28:13 -0000	1.24
+++ sound.cpp	8 Oct 2003 18:02:53 -0000	1.25
@@ -28,6 +28,7 @@
 // ---------------------------------------------------------------------------
 
 #include "stdafx.h"
+#include "bs2/sword2.h"
 #include "bs2/console.h"
 #include "bs2/defs.h"		// for RESULT
 #include "bs2/interpreter.h"
@@ -78,7 +79,7 @@
 		switch (fxq[j].type) {
 		case FX_RANDOM:
 			// 1 in 'delay' chance of this fx occurring
-			if (rand() % fxq[j].delay == 0)
+			if (g_sword2->_rnd.getRandomNumber(fxq[j].delay) == 0)
 				Trigger_fx(j);
 			break;
 		case FX_SPOT:
@@ -190,9 +191,8 @@
 
 	if (fxq[j].type == FX_RANDOM) {
 		// 'delay' param is the intended average no. seconds between
-		// playing this effect (+1 to avoid divide-by-zero in
-		// Process_fx_queue)
-		fxq[j].delay = params[2] * 12 + 1;
+		// playing this effect
+		fxq[j].delay = params[2] * 12;
 	} else {
 		// FX_SPOT or FX_LOOP:
 		//  'delay' is no. frames to wait before playing

Index: sword2.h
===================================================================
RCS file: /cvsroot/scummvm/scummvm/bs2/sword2.h,v
retrieving revision 1.17
retrieving revision 1.18
diff -u -d -r1.17 -r1.18
--- sword2.h	5 Oct 2003 15:28:14 -0000	1.17
+++ sword2.h	8 Oct 2003 18:02:53 -0000	1.18
@@ -71,6 +71,7 @@
 	byte _gameId;
 	char *_game_name; // target name for saves
 	Sound *_sound;
+	Common::RandomSource _rnd;
 
 private:
 	bool _quit;





More information about the Scummvm-git-logs mailing list