[quake3-commits] r2156 - in trunk/code: client server

DONOTREPLY at icculus.org DONOTREPLY at icculus.org
Wed Sep 7 15:38:19 EDT 2011


Author: ztm
Date: 2011-09-07 15:38:19 -0400 (Wed, 07 Sep 2011)
New Revision: 2156

Modified:
   trunk/code/client/cl_main.c
   trunk/code/server/sv_client.c
Log:
Require gamename if not supporting legacy protocol.

Modified: trunk/code/client/cl_main.c
===================================================================
--- trunk/code/client/cl_main.c	2011-08-30 11:57:00 UTC (rev 2155)
+++ trunk/code/client/cl_main.c	2011-09-07 19:38:19 UTC (rev 2156)
@@ -3763,13 +3763,22 @@
 	char	*infoString;
 	int		prot;
 	char	*gamename;
+	qboolean gameMismatch;
 
 	infoString = MSG_ReadString( msg );
 
 	// if this isn't the correct gamename, ignore it
 	gamename = Info_ValueForKey( infoString, "gamename" );
 
-	if (gamename && *gamename && strcmp(gamename, com_gamename->string))
+#ifdef LEGACY_PROTOCOL
+	// gamename is optional for legacy protocol
+	if (com_legacyprotocol->integer && !*gamename)
+		gameMismatch = qfalse;
+	else
+#endif
+		gameMismatch = !*gamename || strcmp(gamename, com_gamename->string) != 0;
+
+	if (gameMismatch)
 	{
 		Com_DPrintf( "Game mismatch in info packet: %s\n", infoString );
 		return;

Modified: trunk/code/server/sv_client.c
===================================================================
--- trunk/code/server/sv_client.c	2011-08-30 11:57:00 UTC (rev 2155)
+++ trunk/code/server/sv_client.c	2011-09-07 19:38:19 UTC (rev 2156)
@@ -60,6 +60,7 @@
 	challenge_t	*challenge;
 	qboolean wasfound = qfalse;
 	char *gameName;
+	qboolean gameMismatch;
 
 	// ignore if we are in single player
 	if ( Cvar_VariableValue( "g_gametype" ) == GT_SINGLE_PLAYER || Cvar_VariableValue("ui_singlePlayerActive")) {
@@ -67,15 +68,21 @@
 	}
 
 	gameName = Cmd_Argv(2);
-	if(gameName && *gameName)
+
+#ifdef LEGACY_PROTOCOL
+	// gamename is optional for legacy protocol
+	if (com_legacyprotocol->integer && !*gameName)
+		gameMismatch = qfalse;
+	else
+#endif
+		gameMismatch = !*gameName || strcmp(gameName, com_gamename->string) != 0;
+
+	// reject client if the gamename string sent by the client doesn't match ours
+	if (gameMismatch)
 	{
-		// reject client if the heartbeat string sent by the client doesn't match ours
-		if(strcmp(gameName, com_gamename->string))
-		{
- 			NET_OutOfBandPrint(NS_SERVER, from, "print\nGame mismatch: This is a %s server\n",
- 				com_gamename->string);
-			return;
-		}
+		NET_OutOfBandPrint(NS_SERVER, from, "print\nGame mismatch: This is a %s server\n",
+			com_gamename->string);
+		return;
 	}
 
 	oldest = 0;



More information about the quake3-commits mailing list