]> icculus.org git repositories - divverent/nexuiz.git/blob - data/qcsrc/client/prandom.qc
Scaled the weapon models down about 30% to match 2.5.2 sizes. Except the tuba, I...
[divverent/nexuiz.git] / data / qcsrc / client / prandom.qc
1 // prandom - PREDICTABLE random number generator (not seeded yet)
2
3 #ifdef USE_PRANDOM
4 float prandom_seed;
5 float prandom()
6 {
7         float c;
8         c = crc16(FALSE, strcat(ftos(prandom_seed), ftos(prandom_seed + M_PI)));
9         prandom_seed = c;
10
11 #ifdef USE_PRANDOM_DEBUG
12         print("RANDOM -> ", ftos(c), "\n");
13 #endif
14
15         return c / 65536; // in [0..1[
16 }
17
18 vector prandomvec()
19 {
20         vector v;
21
22         do
23         {
24                 v_x = prandom();
25                 v_y = prandom();
26                 v_z = prandom();
27         }
28         while(v * v > 1);
29
30         return v;
31 }
32
33 void psrandom(float seed)
34 {
35         prandom_seed = seed;
36 #ifdef USE_PRANDOM_DEBUG
37         print("SRANDOM ", ftos(seed), "\n");
38 #endif
39 }
40
41 #ifdef USE_PRANDOM_DEBUG
42 void prandom_debug()
43 {
44         print("Current random seed = ", ftos(prandom_seed), "\n");
45 }
46 #endif
47 #endif