summaryrefslogtreecommitdiff
path: root/src/common
diff options
context:
space:
mode:
authorMadCamel <madcamel@gmail.com>2009-08-30 19:26:28 -0400
committerMadCamel <madcamel@gmail.com>2009-08-30 19:26:28 -0400
commitdbd9d0321c66deeecf01445f8298aa5076391fbd (patch)
tree6b680d039840b478bb6febd656e128969ae4624c /src/common
parent8acdd39d413cd5a29ab70ca2b8cf22b43ca216b0 (diff)
downloadtmwa-dbd9d0321c66deeecf01445f8298aa5076391fbd.tar.gz
tmwa-dbd9d0321c66deeecf01445f8298aa5076391fbd.tar.bz2
tmwa-dbd9d0321c66deeecf01445f8298aa5076391fbd.tar.xz
tmwa-dbd9d0321c66deeecf01445f8298aa5076391fbd.zip
MRAND() no longer uses high-order bits
Diffstat (limited to 'src/common')
-rw-r--r--src/common/utils.h5
1 files changed, 2 insertions, 3 deletions
diff --git a/src/common/utils.h b/src/common/utils.h
index ba96da1..0b006c3 100644
--- a/src/common/utils.h
+++ b/src/common/utils.h
@@ -34,10 +34,9 @@
/*
* ModuloRand and ModuloPlusRand. These macros are used to replace the
- * vast number of calls to rand()%mod which is low-order bits. These
- * instead use the high-order bits as suggested in the man page of rand().
+ * vast number of calls to rand()%mod ..
* MRAND(10), returns 0-9.
* MPRAND(5,10) returns 5-14.
*/
-#define MRAND(mod) (int) ((float)mod * (mt_random() / (RAND_MAX + 1.0)))
+#define MRAND(mod) (int) (mt_random() % mod)
#define MPRAND(add, mod) add + MRAND(mod)