summaryrefslogtreecommitdiff
path: root/src/map/magic-expr.c
diff options
context:
space:
mode:
authorMadCamel <madcamel@gmail.com>2009-09-16 07:49:36 -0400
committerMadCamel <madcamel@gmail.com>2009-09-16 07:49:36 -0400
commit03149635727f16b45e99fd5f2f3647d6c4cb749f (patch)
tree4b9f06028bd79a152e485629e175b76447d33b98 /src/map/magic-expr.c
parentd7b6afc444c1fac508dd5cc4bdf7e4dfa57e50c2 (diff)
downloadtmwa-03149635727f16b45e99fd5f2f3647d6c4cb749f.tar.gz
tmwa-03149635727f16b45e99fd5f2f3647d6c4cb749f.tar.bz2
tmwa-03149635727f16b45e99fd5f2f3647d6c4cb749f.tar.xz
tmwa-03149635727f16b45e99fd5f2f3647d6c4cb749f.zip
Found and replaced more calls to rand()
Diffstat (limited to 'src/map/magic-expr.c')
-rw-r--r--src/map/magic-expr.c17
1 files changed, 8 insertions, 9 deletions
diff --git a/src/map/magic-expr.c b/src/map/magic-expr.c
index c136a17..9d3c751 100644
--- a/src/map/magic-expr.c
+++ b/src/map/magic-expr.c
@@ -607,8 +607,6 @@ fun_location(env_t *env, int args_nr, val_t *result, val_t *args)
return 0;
}
-/* Recall that glibc's rand() isnt' too bad in the lower bits */
-
static int
fun_random(env_t *env, int args_nr, val_t *result, val_t *args)
{
@@ -619,7 +617,8 @@ fun_random(env_t *env, int args_nr, val_t *result, val_t *args)
RESULTINT = 0;
return 0;
}
- RESULTINT = rand() % delta;
+ RESULTINT = MRAND(delta);
+
if (ARGINT(0) < 0)
RESULTINT = -RESULTINT;
return 0;
@@ -629,9 +628,9 @@ static int
fun_random_dir(env_t *env, int args_nr, val_t *result, val_t *args)
{
if (ARGINT(0))
- RESULTDIR = rand() & 0x7;
+ RESULTDIR = mt_random() & 0x7;
else
- RESULTDIR = (rand() & 0x3) * 2;
+ RESULTDIR = (mt_random() & 0x3) * 2;
return 0;
}
@@ -850,7 +849,7 @@ magic_random_location(location_t *dest, area_t *area)
{
switch (area->ty) {
case AREA_UNION: {
- int rv = rand() % area->size;
+ int rv = MRAND(area->size);
if (rv < area->a.a_union[0]->size)
magic_random_location(dest, area->a.a_union[0]);
else
@@ -870,14 +869,14 @@ magic_random_location(location_t *dest, area_t *area)
if (h <= 1)
h = 1;
- x += rand() % w;
- y += rand() % h;
+ x += MRAND(w);
+ y += MRAND(h);
if (!map_is_solid(m, x, y)) {
int start_x = x;
int start_y = y;
int i;
- int initial_dir = rand() & 0x7;
+ int initial_dir = mt_random() & 0x7;
int dir = initial_dir;
/* try all directions, up to a distance to 10, for a free slot */