mirror of
https://github.com/UberGames/ioef.git
synced 2025-01-18 23:21:37 +00:00
Revert changes of rand() to random() as random() was redefined in quake3.
This commit is contained in:
parent
b40f1507ea
commit
e4d0c14f70
5 changed files with 17 additions and 11 deletions
|
@ -1306,8 +1306,12 @@ void CL_RequestMotd( void ) {
|
||||||
BigShort( cls.updateServer.port ) );
|
BigShort( cls.updateServer.port ) );
|
||||||
|
|
||||||
info[0] = 0;
|
info[0] = 0;
|
||||||
|
// NOTE TTimo xoring against Com_Milliseconds, otherwise we may not have a true randomization
|
||||||
Com_sprintf( cls.updateChallenge, sizeof( cls.updateChallenge ), "%i", (random() << 16) ^ random());
|
// only srand I could catch before here is tr_noise.c l:26 srand(1001)
|
||||||
|
// https://zerowing.idsoftware.com/bugzilla/show_bug.cgi?id=382
|
||||||
|
// NOTE: the Com_Milliseconds xoring only affects the lower 16-bit word,
|
||||||
|
// but I decided it was enough randomization
|
||||||
|
Com_sprintf( cls.updateChallenge, sizeof( cls.updateChallenge ), "%i", ((rand() << 16) ^ rand()) ^ Com_Milliseconds());
|
||||||
|
|
||||||
Info_SetValueForKey( info, "challenge", cls.updateChallenge );
|
Info_SetValueForKey( info, "challenge", cls.updateChallenge );
|
||||||
Info_SetValueForKey( info, "renderer", cls.glconfig.renderer_string );
|
Info_SetValueForKey( info, "renderer", cls.glconfig.renderer_string );
|
||||||
|
|
|
@ -2499,7 +2499,6 @@ static void Com_DetectAltivec(void)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
=================
|
=================
|
||||||
Com_InitRand
|
Com_InitRand
|
||||||
|
@ -2510,7 +2509,7 @@ static void Com_InitRand(void)
|
||||||
{
|
{
|
||||||
unsigned int seed;
|
unsigned int seed;
|
||||||
|
|
||||||
if(Sys_Random(&seed, sizeof(seed)))
|
if(Sys_RandomBytes(&seed, sizeof(seed)))
|
||||||
srand(seed);
|
srand(seed);
|
||||||
else
|
else
|
||||||
srand(time(NULL));
|
srand(time(NULL));
|
||||||
|
@ -3341,7 +3340,8 @@ void Com_RandomBytes( byte *string, int len )
|
||||||
return;
|
return;
|
||||||
|
|
||||||
Com_Printf( "Com_RandomBytes: using weak randomization\n" );
|
Com_Printf( "Com_RandomBytes: using weak randomization\n" );
|
||||||
|
srand( time( 0 ) );
|
||||||
for( i = 0; i < len; i++ )
|
for( i = 0; i < len; i++ )
|
||||||
string[i] = (unsigned char)( random() % 255 );
|
string[i] = (unsigned char)( rand() % 255 );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -44,10 +44,12 @@ void R_NoiseInit( void )
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
|
srand( 1001 );
|
||||||
|
|
||||||
for ( i = 0; i < NOISE_SIZE; i++ )
|
for ( i = 0; i < NOISE_SIZE; i++ )
|
||||||
{
|
{
|
||||||
s_noise_table[i] = ( float ) ( ( ( random() / ( float ) RAND_MAX ) * 2.0 - 1.0 ) );
|
s_noise_table[i] = ( float ) ( ( ( rand() / ( float ) RAND_MAX ) * 2.0 - 1.0 ) );
|
||||||
s_noise_perm[i] = ( unsigned char ) ( random() / ( float ) RAND_MAX * 255 );
|
s_noise_perm[i] = ( unsigned char ) ( rand() / ( float ) RAND_MAX * 255 );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -72,8 +72,7 @@ void SV_GetChallenge( netadr_t from ) {
|
||||||
if (i == MAX_CHALLENGES) {
|
if (i == MAX_CHALLENGES) {
|
||||||
// this is the first time this client has asked for a challenge
|
// this is the first time this client has asked for a challenge
|
||||||
challenge = &svs.challenges[oldest];
|
challenge = &svs.challenges[oldest];
|
||||||
|
challenge->challenge = ( (rand() << 16) ^ rand() ) ^ svs.time;
|
||||||
challenge->challenge = ( (random() << 16) ^ random() ) ^ svs.time;
|
|
||||||
challenge->adr = from;
|
challenge->adr = from;
|
||||||
challenge->firstTime = svs.time;
|
challenge->firstTime = svs.time;
|
||||||
challenge->time = svs.time;
|
challenge->time = svs.time;
|
||||||
|
|
|
@ -475,7 +475,8 @@ void SV_SpawnServer( char *server, qboolean killBots ) {
|
||||||
Cvar_Set("cl_paused", "0");
|
Cvar_Set("cl_paused", "0");
|
||||||
|
|
||||||
// get a new checksum feed and restart the file system
|
// get a new checksum feed and restart the file system
|
||||||
sv.checksumFeed = ( ((int) random() << 16) ^ random() ) ^ Com_Milliseconds();
|
srand(Com_Milliseconds());
|
||||||
|
sv.checksumFeed = ( ((int) rand() << 16) ^ rand() ) ^ Com_Milliseconds();
|
||||||
FS_Restart( sv.checksumFeed );
|
FS_Restart( sv.checksumFeed );
|
||||||
|
|
||||||
CM_LoadMap( va("maps/%s.bsp", server), qfalse, &checksum );
|
CM_LoadMap( va("maps/%s.bsp", server), qfalse, &checksum );
|
||||||
|
|
Loading…
Reference in a new issue