From 95548cb1caad95933e2b36df9a13af070b733b04 Mon Sep 17 00:00:00 2001 From: gepard1984 Date: Tue, 17 Jan 2012 18:06:34 +0000 Subject: Enabled Mersenne Twister MT19937 as random number generator instead of standard `rand()` function (follow-up to r14865, r14870). - It fixes issues caused by RAND_MAX being only 32k in Windows system (bugreport:1927, bugreport:86). git-svn-id: https://rathena.svn.sourceforge.net/svnroot/rathena/trunk@15483 54d463be-8e91-2dee-dedb-b68131a5f0ec --- src/map/script.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) (limited to 'src/map/script.c') diff --git a/src/map/script.c b/src/map/script.c index 274903a7a..ca29ebb71 100644 --- a/src/map/script.c +++ b/src/map/script.c @@ -12,6 +12,7 @@ #include "../common/md5calc.h" #include "../common/lock.h" #include "../common/nullpo.h" +#include "../common/random.h" #include "../common/showmsg.h" #include "../common/strlib.h" #include "../common/timer.h" @@ -4448,12 +4449,8 @@ BUILDIN_FUNC(rand) } if( range <= 1 ) script_pushint(st, min); - else if( range > SHRT_MAX ) { - int step1 = rand()%(range&0xffff), step2 = rand()%(range>>16); - script_pushint(st, step1 + (step2<<16) + min); - } else - script_pushint(st, rand()%range + min); + script_pushint(st, rnd()%range + min); return 0; } -- cgit v1.2.3-60-g2f50