Use RandomSource instead of rand().
svn-id: r10682
This commit is contained in:
parent
a1f4dc2c90
commit
a29d128bd3
4 changed files with 9 additions and 8 deletions
|
@ -24,7 +24,7 @@
|
||||||
// ---------------------------------------------------------------------------
|
// ---------------------------------------------------------------------------
|
||||||
|
|
||||||
#include "stdafx.h"
|
#include "stdafx.h"
|
||||||
#include "common/scummsys.h"
|
#include "bs2/sword2.h"
|
||||||
#include "bs2/driver/driver96.h"
|
#include "bs2/driver/driver96.h"
|
||||||
#include "bs2/driver/d_draw.h"
|
#include "bs2/driver/d_draw.h"
|
||||||
#include "bs2/anims.h"
|
#include "bs2/anims.h"
|
||||||
|
|
|
@ -135,11 +135,11 @@ int32 FN_random(int32 *params) {
|
||||||
// Generates a random number between 'min' & 'max' inclusive, and
|
// Generates a random number between 'min' & 'max' inclusive, and
|
||||||
// sticks it in the script flag 'result'
|
// sticks it in the script flag 'result'
|
||||||
|
|
||||||
uint32 min = params[0];
|
// params: 0 min
|
||||||
uint32 max = params[1];
|
// 1 max
|
||||||
|
|
||||||
// return_value = random integer between min and max, inclusive
|
// 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
|
// continue script
|
||||||
return IR_CONT;
|
return IR_CONT;
|
||||||
|
|
|
@ -28,6 +28,7 @@
|
||||||
// ---------------------------------------------------------------------------
|
// ---------------------------------------------------------------------------
|
||||||
|
|
||||||
#include "stdafx.h"
|
#include "stdafx.h"
|
||||||
|
#include "bs2/sword2.h"
|
||||||
#include "bs2/console.h"
|
#include "bs2/console.h"
|
||||||
#include "bs2/defs.h" // for RESULT
|
#include "bs2/defs.h" // for RESULT
|
||||||
#include "bs2/interpreter.h"
|
#include "bs2/interpreter.h"
|
||||||
|
@ -78,7 +79,7 @@ void Process_fx_queue(void) {
|
||||||
switch (fxq[j].type) {
|
switch (fxq[j].type) {
|
||||||
case FX_RANDOM:
|
case FX_RANDOM:
|
||||||
// 1 in 'delay' chance of this fx occurring
|
// 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);
|
Trigger_fx(j);
|
||||||
break;
|
break;
|
||||||
case FX_SPOT:
|
case FX_SPOT:
|
||||||
|
@ -190,9 +191,8 @@ int32 FN_play_fx(int32 *params) {
|
||||||
|
|
||||||
if (fxq[j].type == FX_RANDOM) {
|
if (fxq[j].type == FX_RANDOM) {
|
||||||
// 'delay' param is the intended average no. seconds between
|
// 'delay' param is the intended average no. seconds between
|
||||||
// playing this effect (+1 to avoid divide-by-zero in
|
// playing this effect
|
||||||
// Process_fx_queue)
|
fxq[j].delay = params[2] * 12;
|
||||||
fxq[j].delay = params[2] * 12 + 1;
|
|
||||||
} else {
|
} else {
|
||||||
// FX_SPOT or FX_LOOP:
|
// FX_SPOT or FX_LOOP:
|
||||||
// 'delay' is no. frames to wait before playing
|
// 'delay' is no. frames to wait before playing
|
||||||
|
|
|
@ -71,6 +71,7 @@ public:
|
||||||
byte _gameId;
|
byte _gameId;
|
||||||
char *_game_name; // target name for saves
|
char *_game_name; // target name for saves
|
||||||
Sound *_sound;
|
Sound *_sound;
|
||||||
|
Common::RandomSource _rnd;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
bool _quit;
|
bool _quit;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue