Require gamename if not supporting legacy protocol.

This commit is contained in:
Zack Middleton 2011-09-07 19:38:19 +00:00
parent 1a736dd725
commit d9b72dedc1
2 changed files with 25 additions and 9 deletions

View File

@ -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;

View File

@ -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;