mirror of
https://github.com/libretro/scummvm.git
synced 2025-02-26 14:27:14 +00:00
Use RandomSource instead of rand().
svn-id: r10682
This commit is contained in:
parent
a1f4dc2c90
commit
a29d128bd3
@ -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"
|
||||
|
@ -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;
|
||||
|
@ -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
|
||||
|
@ -71,6 +71,7 @@ public:
|
||||
byte _gameId;
|
||||
char *_game_name; // target name for saves
|
||||
Sound *_sound;
|
||||
Common::RandomSource _rnd;
|
||||
|
||||
private:
|
||||
bool _quit;
|
||||
|
Loading…
x
Reference in New Issue
Block a user