diff options
author | Jared Adams <jaxad0127@gmail.com> | 2009-10-15 06:38:48 -0600 |
---|---|---|
committer | Jared Adams <jaxad0127@gmail.com> | 2009-10-15 06:38:48 -0600 |
commit | d6dbf554bd866124b7c676187c351c3f67fd3906 (patch) | |
tree | 2301dbf20ee0994963ccebfd1c5f7fd73e08a200 /src/map/magic-expr.c | |
parent | a11a55e91bd25f52eac46a99f4c906e773245046 (diff) | |
parent | 29844ce5e2cd043551b46c1cd7bf3a36e357e3c6 (diff) | |
download | tmwa-d6dbf554bd866124b7c676187c351c3f67fd3906.tar.gz tmwa-d6dbf554bd866124b7c676187c351c3f67fd3906.tar.bz2 tmwa-d6dbf554bd866124b7c676187c351c3f67fd3906.tar.xz tmwa-d6dbf554bd866124b7c676187c351c3f67fd3906.zip |
Merge remote branch 'taw/master'
Diffstat (limited to 'src/map/magic-expr.c')
-rw-r--r-- | src/map/magic-expr.c | 17 |
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 */ |