diff --git a/src/common/header/common.h b/src/common/header/common.h index 88fba834..6d4a9e5d 100644 --- a/src/common/header/common.h +++ b/src/common/header/common.h @@ -699,9 +699,6 @@ void Com_SetServerState (int state); unsigned Com_BlockChecksum (void *buffer, int length); byte COM_BlockSequenceCRCByte (byte *base, int length, int sequence); -float frand(void); /* 0 ti 1 */ -float crand(void); /* -1 to 1 */ - extern cvar_t *developer; extern cvar_t *modder; extern cvar_t *dedicated; @@ -759,6 +756,8 @@ void SV_Frame (int msec); /* Random number generator */ int randk(void); +float frandk(void); +float crandk(void); void randk_seed(void); #endif diff --git a/src/common/misc.c b/src/common/misc.c index 9624375e..1eb08e8d 100644 --- a/src/common/misc.c +++ b/src/common/misc.c @@ -157,16 +157,6 @@ byte COM_BlockSequenceCRCByte (byte *base, int length, int sequence) return r; } -float frand(void) -{ - return (rand()&32767)* (1.0/32767); -} - -float crand(void) -{ - return (rand()&32767)* (2.0/32767) - 1; -} - #ifndef DEDICATED_ONLY void Key_Init (void); void SCR_EndLoadingPlaque (void); diff --git a/src/common/rand.c b/src/common/rand.c index 6a60508f..c2b97b2c 100644 --- a/src/common/rand.c +++ b/src/common/rand.c @@ -25,7 +25,7 @@ static int j; static uint64_t carry; static uint64_t xs; static uint64_t cng; - + uint64_t B64MWC(void) { @@ -36,7 +36,7 @@ B64MWC(void) t = (x << 28) + carry; carry = (x >> 36) - (t < x); return QARY[j] = t - x; -} +} /* * Generate a pseudorandom @@ -47,7 +47,30 @@ randk(void) { return (int)KISS; } - + +/* + * Generate a pseudorandom + * signed float between + * 0 and 1. + */ +float +frandk(void) +{ + return (randk()&32767)* (1.0/32767); +} + +/* Generate a pseudorandom + * float between -1 and 1. + */ +float +crandk(void) +{ + return (randk()&32767)* (2.0/32767) - 1; +} + +/* + * Seeds the PRNG + */ void randk_seed(void) {