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