summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorZack Middleton <zturtleman@gmail.com>2011-09-07 19:38:19 +0000
committerTim Angus <tim@ngus.net>2013-01-10 23:37:49 +0000
commita5802640d1ecf2b7b87f1dd861b0563665bd0df3 (patch)
tree9ba86610df90c2cfebd0f1374aaeae0a3bb3c87f
parent9833bc56325e943fbdef9e736b786135d3ea8189 (diff)
Require gamename if not supporting legacy protocol.
-rw-r--r--src/client/cl_main.c11
-rw-r--r--src/server/sv_client.c23
2 files changed, 25 insertions, 9 deletions
diff --git a/src/client/cl_main.c b/src/client/cl_main.c
index aee69445..58618f19 100644
--- a/src/client/cl_main.c
+++ b/src/client/cl_main.c
@@ -3819,13 +3819,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/src/server/sv_client.c b/src/server/sv_client.c
index f3d190de..93519177 100644
--- a/src/server/sv_client.c
+++ b/src/server/sv_client.c
@@ -61,17 +61,24 @@ void SV_GetChallenge(netadr_t from)
challenge_t *challenge;
qboolean wasfound = qfalse;
char *gameName;
+ qboolean gameMismatch;
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;