diff --git a/code/client/cl_main.c b/code/client/cl_main.c index aa87b47c..2606f6d8 100644 --- a/code/client/cl_main.c +++ b/code/client/cl_main.c @@ -3763,13 +3763,22 @@ void CL_ServerInfoPacket( netadr_t from, msg_t *msg ) { 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; diff --git a/code/server/sv_client.c b/code/server/sv_client.c index a7ba1101..0326782b 100644 --- a/code/server/sv_client.c +++ b/code/server/sv_client.c @@ -60,6 +60,7 @@ void SV_GetChallenge(netadr_t from) 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 @@ void SV_GetChallenge(netadr_t from) } 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;