r1506 - trunk/code/qcommon

DONOTREPLY at icculus.org DONOTREPLY at icculus.org
Mon Mar 2 13:08:15 EST 2009


Author: ludwig
Date: 2009-03-02 13:08:13 -0500 (Mon, 02 Mar 2009)
New Revision: 1506

Modified:
   trunk/code/qcommon/common.c
Log:
initialize qport with random value instead of time (#3999)

Modified: trunk/code/qcommon/common.c
===================================================================
--- trunk/code/qcommon/common.c	2009-03-02 17:29:51 UTC (rev 1505)
+++ trunk/code/qcommon/common.c	2009-03-02 18:08:13 UTC (rev 1506)
@@ -2509,6 +2509,7 @@
 */
 void Com_Init( char *commandLine ) {
 	char	*s;
+	int	qport;
 
 	Com_Printf( "%s %s %s\n", Q3_VERSION, PLATFORM_STRING, __DATE__ );
 
@@ -2627,7 +2628,13 @@
 	com_version = Cvar_Get ("version", s, CVAR_ROM | CVAR_SERVERINFO );
 
 	Sys_Init();
-	Netchan_Init( Com_Milliseconds() & 0xffff );	// pick a port value that should be nice and random
+
+	// Pick a port value that should be nice and random.
+	// As machines get faster Com_Milliseconds can't be used
+	// anymore as it results in a smaller and smaller range of
+	// qport values.
+	Com_RandomBytes( (byte*)&qport, sizeof(int) );
+	Netchan_Init( qport & 0xffff );
 	VM_Init();
 	SV_Init();
 




More information about the quake3-commits mailing list