Implement crandk() and frandk() and remove old functions

This commit is contained in:
Yamagi Burmeister 2012-06-02 11:13:25 +02:00
parent 253373dbda
commit 28c200a2e8
3 changed files with 28 additions and 16 deletions

View file

@ -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

View file

@ -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);

View file

@ -48,6 +48,29 @@ 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)
{