diff options
author | MadCamel <madcamel@gmail.com> | 2009-09-30 13:42:54 -0400 |
---|---|---|
committer | MadCamel <madcamel@gmail.com> | 2009-09-30 13:50:33 -0400 |
commit | 765c84f370747e35902757b6771368009ae2a8f6 (patch) | |
tree | 5a2d64474535e6717cc8f186ff684618da00f1b1 /src | |
parent | b396c9ae5d7fab3e13cff70e2a8ebc080aeeb472 (diff) | |
download | tmwa-765c84f370747e35902757b6771368009ae2a8f6.tar.gz tmwa-765c84f370747e35902757b6771368009ae2a8f6.tar.bz2 tmwa-765c84f370747e35902757b6771368009ae2a8f6.tar.xz tmwa-765c84f370747e35902757b6771368009ae2a8f6.zip |
Added -fno-strict-aliasing to CFLAGS This will likely fix a few minor weirdnesses, and compiler warnings.
Diffstat (limited to 'src')
-rw-r--r-- | src/common/mt_rand.c | 9 | ||||
-rw-r--r-- | src/common/mt_rand.h | 1 | ||||
-rw-r--r-- | src/common/utils.h | 2 |
3 files changed, 11 insertions, 1 deletions
diff --git a/src/common/mt_rand.c b/src/common/mt_rand.c index ab733ae..fc9a9ec 100644 --- a/src/common/mt_rand.c +++ b/src/common/mt_rand.c @@ -108,3 +108,12 @@ unsigned long mt_random(void) y ^= (y << 15) & 0xEFC60000U; return(y ^ (y >> 18)); } + +int mt_rand(void) { + unsigned long r = mt_random(); + while (r >> 16) + r = (r & 0xFFFF) + (r >> 16); + + return(r); +} + diff --git a/src/common/mt_rand.h b/src/common/mt_rand.h index 07f6ef0..bda5861 100644 --- a/src/common/mt_rand.h +++ b/src/common/mt_rand.h @@ -4,5 +4,6 @@ void mt_seed(unsigned long seed); unsigned long mt_reload(void); unsigned long mt_random(void); +int mt_rand(void); #endif /* __mt_rand_h */ diff --git a/src/common/utils.h b/src/common/utils.h index 0b006c3..3493808 100644 --- a/src/common/utils.h +++ b/src/common/utils.h @@ -38,5 +38,5 @@ * MRAND(10), returns 0-9. * MPRAND(5,10) returns 5-14. */ -#define MRAND(mod) (int) (mt_random() % mod) +#define MRAND(mod) (mt_rand() % mod) #define MPRAND(add, mod) add + MRAND(mod) |