diff options
-rw-r--r-- | src/map/script.c | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/src/map/script.c b/src/map/script.c index c9cb65f63..6b051dba0 100644 --- a/src/map/script.c +++ b/src/map/script.c @@ -4448,6 +4448,10 @@ 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); |