mirror of
https://git.do.srb2.org/KartKrew/Kart-Public.git
synced 2024-11-10 23:31:50 +00:00
Compensate for insufficient RAND_MAX values.
This commit is contained in:
parent
ac03ce39c8
commit
a3e940fe65
1 changed files with 7 additions and 1 deletions
|
@ -32,7 +32,13 @@
|
||||||
*/
|
*/
|
||||||
fixed_t M_RandomFixed(void)
|
fixed_t M_RandomFixed(void)
|
||||||
{
|
{
|
||||||
|
#if RAND_MAX < 65535
|
||||||
|
// Compensate for insufficient randomness.
|
||||||
|
fixed_t rndv = (rand()&1)<<15;
|
||||||
|
return rand()^rndv;
|
||||||
|
#else
|
||||||
return (rand() & 0xFFFF);
|
return (rand() & 0xFFFF);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Provides a random byte. Distribution is uniform.
|
/** Provides a random byte. Distribution is uniform.
|
||||||
|
@ -246,5 +252,5 @@ void P_SetRandSeedD(const char *rfile, INT32 rline, UINT32 seed)
|
||||||
*/
|
*/
|
||||||
UINT32 M_RandomizedSeed(void)
|
UINT32 M_RandomizedSeed(void)
|
||||||
{
|
{
|
||||||
return ((totalplaytime & 0xFFFF) << 16)|(rand() & 0xFFFF);
|
return ((totalplaytime & 0xFFFF) << 16)|M_RandomFixed();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue