aboutsummaryrefslogtreecommitdiff
path: root/sword2
diff options
context:
space:
mode:
authorTorbjörn Andersson2003-10-08 18:02:53 +0000
committerTorbjörn Andersson2003-10-08 18:02:53 +0000
commita29d128bd3b53847de3e89801426dfc19e2ecbc1 (patch)
tree4b1995fcc900709d75877e7ee053092d17b92ad0 /sword2
parenta1f4dc2c90efd28d30eec2b947ffe9d619ad0989 (diff)
downloadscummvm-rg350-a29d128bd3b53847de3e89801426dfc19e2ecbc1.tar.gz
scummvm-rg350-a29d128bd3b53847de3e89801426dfc19e2ecbc1.tar.bz2
scummvm-rg350-a29d128bd3b53847de3e89801426dfc19e2ecbc1.zip
Use RandomSource instead of rand().
svn-id: r10682
Diffstat (limited to 'sword2')
-rw-r--r--sword2/anims.cpp2
-rw-r--r--sword2/function.cpp6
-rw-r--r--sword2/sound.cpp8
-rw-r--r--sword2/sword2.h1
4 files changed, 9 insertions, 8 deletions
diff --git a/sword2/anims.cpp b/sword2/anims.cpp
index 9ef4f83e1c..988eea2449 100644
--- a/sword2/anims.cpp
+++ b/sword2/anims.cpp
@@ -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"
diff --git a/sword2/function.cpp b/sword2/function.cpp
index 1d8e588861..b3040eff75 100644
--- a/sword2/function.cpp
+++ b/sword2/function.cpp
@@ -135,11 +135,11 @@ int32 FN_random(int32 *params) {
// 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;
diff --git a/sword2/sound.cpp b/sword2/sound.cpp
index cd9c5157be..9c6c72aa85 100644
--- a/sword2/sound.cpp
+++ b/sword2/sound.cpp
@@ -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 @@ void Process_fx_queue(void) {
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 @@ int32 FN_play_fx(int32 *params) {
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
diff --git a/sword2/sword2.h b/sword2/sword2.h
index 8d592879ae..0e0fd28447 100644
--- a/sword2/sword2.h
+++ b/sword2/sword2.h
@@ -71,6 +71,7 @@ public:
byte _gameId;
char *_game_name; // target name for saves
Sound *_sound;
+ Common::RandomSource _rnd;
private:
bool _quit;