]> icculus.org git repositories - btb/d2x.git/blob - maths/rand.c
fix NDEBUG calloc macro
[btb/d2x.git] / maths / rand.c
1 /* $Id: */
2 /*
3  * Descent random number stuff...
4  * rand has different ranges on different machines...
5  */
6
7 #ifdef HAVE_CONFIG_H
8 #include <conf.h>
9 #endif
10
11 #include <stdlib.h>
12
13 #ifdef NO_WATCOM_RAND
14 void d_srand(unsigned int seed)
15 {
16  srand(seed);
17 }
18
19 int d_rand()
20 {
21  return rand()&0x7fff;
22 }
23 #else
24 static unsigned int d_rand_seed;
25
26 int d_rand() {
27         return ((d_rand_seed = d_rand_seed * 0x41c64e6d + 0x3039) >> 16) & 0x7fff;
28 }
29
30 void d_srand(unsigned int seed) {
31         d_rand_seed = seed;
32 }
33 #endif