Index: README =================================================================== --- README (revision 2102) +++ README (working copy) @@ -120,8 +120,6 @@ cl_mouseAccelStyle - Set to 1 for QuakeLive mouse acceleration behaviour, 0 for standard q3 cl_mouseAccelOffset - Tuning the acceleration curve, see below - cl_gamename - Gamename sent to master server in - getserversExt query in_joystickUseAnalog - Do not translate joystick axis events to keyboard commands @@ -197,6 +195,10 @@ through which other processes can control the server while it is running. Nonfunctional on Windows. + com_gamename - Gamename sent to master server in + getservers[Ext] query and infoResponse + "gamename" infostring value. Also used + for filtering local network games. com_protocol - Specify protocol version number for current ioquake3 protocol, see "Network protocols" section below @@ -531,21 +533,21 @@ the master server: +set sv_heartbeat +set sv_flatline - +set cl_gamename + +set com_gamename The and message can be specific to your game. The flatline message is sent to signal the master server that the game server is quitting. Vanilla quake3 uses "QuakeArena-1" both for the heartbeat and flatline messages. - The cl_gamename message is for dpmaster to specify which game the client - wants a server list for. It is only used in the new ipv6 based getServersExt - query. + The com_gamename message is for dpmaster to specify which game the server + want to host for and which game client wants a server list for. Also used by + client to filter local network games for server browser. Example line: +set com_basegame basefoo +set com_homepath .foo +set sv_heartbeat fooalive +set sv_flatline foodead - +set cl_gamename foo + +set com_gamename foo If you really changed parts that would make vanilla ioquake3 incompatible with Index: code/server/sv_client.c =================================================================== --- code/server/sv_client.c (revision 2102) +++ code/server/sv_client.c (working copy) @@ -59,23 +59,26 @@ int clientChallenge; challenge_t *challenge; qboolean wasfound = qfalse; - char *gameName; + char *gamename; // ignore if we are in single player if ( Cvar_VariableValue( "g_gametype" ) == GT_SINGLE_PLAYER || Cvar_VariableValue("ui_singlePlayerActive")) { return; } - gameName = Cmd_Argv(2); - if(gameName && *gameName) + gamename = Cmd_Argv(2); + + // reject client if the gamename string sent by the client doesn't match ours +#ifdef LEGACY_PROTOCOL + if ((com_legacyprotocol->integer && gamename && *gamename && strcmp(gamename, GAMENAME_FOR_SERVER)) + || (!com_legacyprotocol->integer && (!gamename || !*gamename || strcmp(gamename, GAMENAME_FOR_SERVER)))) +#else + if(!gamename || !*gamename || strcmp(gamename, GAMENAME_FOR_SERVER)) +#endif { - // reject client if the heartbeat string sent by the client doesn't match ours - if(strcmp(gameName, sv_heartbeat->string)) - { - NET_OutOfBandPrint(NS_SERVER, from, "print\nGame mismatch: This is a %s server\n", - sv_heartbeat->string); - return; - } + NET_OutOfBandPrint(NS_SERVER, from, "print\nGame mismatch: This is a %s server%s\n", + GAMENAME_FOR_SERVER, (gamename && *gamename) ? va(" (not %s)", gamename) : ""); + return; } oldest = 0; Index: code/server/sv_main.c =================================================================== --- code/server/sv_main.c (revision 2102) +++ code/server/sv_main.c (working copy) @@ -644,6 +644,8 @@ // to prevent timed spoofed reply packets that add ghost servers Info_SetValueForKey( infostring, "challenge", Cmd_Argv(1) ); + Info_SetValueForKey( infostring, "gamename", com_gamename->string ); + #ifdef LEGACY_PROTOCOL if(com_legacyprotocol->integer > 0) Info_SetValueForKey(infostring, "protocol", va("%i", com_legacyprotocol->integer)); Index: code/qcommon/q_shared.h =================================================================== --- code/qcommon/q_shared.h (revision 2102) +++ code/qcommon/q_shared.h (working copy) @@ -31,27 +31,29 @@ #define BASEGAME "foobar" #define CLIENT_WINDOW_TITLE "changeme" #define CLIENT_WINDOW_MIN_TITLE "changeme2" - #define GAMENAME_FOR_MASTER "iofoo3" // must NOT contain whitespaces - #define HEARTBEAT_FOR_MASTER GAMENAME_FOR_MASTER - #define FLATLINE_FOR_MASTER GAMENAME_FOR_MASTER "dead" #define HOMEPATH_NAME_UNIX ".foo" #define HOMEPATH_NAME_WIN "FooBar" #define HOMEPATH_NAME_MACOSX HOMEPATH_NAME_WIN + #define GAMENAME_FOR_SERVER "ChangeMe" + #define GAMENAME_FOR_MASTER GAMENAME_FOR_SERVER // must NOT contain whitespaces // #define LEGACY_PROTOCOL // You probably don't need this for your standalone game #else #define PRODUCT_NAME "ioq3" #define BASEGAME "baseq3" #define CLIENT_WINDOW_TITLE "ioquake3" #define CLIENT_WINDOW_MIN_TITLE "ioq3" - #define GAMENAME_FOR_MASTER "Quake3Arena" - #define HEARTBEAT_FOR_MASTER "QuakeArena-1" - #define FLATLINE_FOR_MASTER HEARTBEAT_FOR_MASTER #define HOMEPATH_NAME_UNIX ".q3a" #define HOMEPATH_NAME_WIN "Quake3" #define HOMEPATH_NAME_MACOSX HOMEPATH_NAME_WIN + #define GAMENAME_FOR_SERVER "QuakeArena-1" + #define GAMENAME_FOR_MASTER "Quake3Arena" #define LEGACY_PROTOCOL #endif +// Heartbeat for dpmaster protocol +#define HEARTBEAT_FOR_MASTER "DarkPlaces" +#define FLATLINE_FOR_MASTER HEARTBEAT_FOR_MASTER + #define BASETA "missionpack" #ifndef PRODUCT_VERSION Index: code/qcommon/qcommon.h =================================================================== --- code/qcommon/qcommon.h (revision 2102) +++ code/qcommon/qcommon.h (working copy) @@ -870,6 +870,7 @@ extern cvar_t *cl_packetdelay; extern cvar_t *sv_packetdelay; +extern cvar_t *com_gamename; extern cvar_t *com_protocol; #ifdef LEGACY_PROTOCOL extern cvar_t *com_legacyprotocol; Index: code/qcommon/common.c =================================================================== --- code/qcommon/common.c (revision 2102) +++ code/qcommon/common.c (working copy) @@ -85,6 +85,7 @@ cvar_t *com_maxfpsMinimized; cvar_t *com_abnormalExit; cvar_t *com_standalone; +cvar_t *com_gamename; cvar_t *com_protocol; #ifdef LEGACY_PROTOCOL cvar_t *com_legacyprotocol; @@ -2787,6 +2788,7 @@ s = va("%s %s %s", Q3_VERSION, PLATFORM_STRING, __DATE__ ); com_version = Cvar_Get ("version", s, CVAR_ROM | CVAR_SERVERINFO ); + com_gamename = Cvar_Get("com_gamename", GAMENAME_FOR_MASTER, CVAR_SERVERINFO | CVAR_INIT); com_protocol = Cvar_Get("com_protocol", va("%i", PROTOCOL_VERSION), CVAR_SERVERINFO | CVAR_INIT); #ifdef LEGACY_PROTOCOL com_legacyprotocol = Cvar_Get("com_legacyprotocol", va("%i", PROTOCOL_LEGACY_VERSION), CVAR_INIT); Index: code/client/cl_main.c =================================================================== --- code/client/cl_main.c (revision 2102) +++ code/client/cl_main.c (working copy) @@ -109,8 +109,6 @@ cvar_t *cl_consoleKeys; -cvar_t *cl_gamename; - clientActive_t cl; clientConnection_t clc; clientStatic_t cls; @@ -2309,9 +2307,9 @@ #endif // The challenge request shall be followed by a client challenge so no malicious server can hijack this connection. - // Add the heartbeat gamename so the server knows we're running the correct game and can reject the client + // Add the gamename so the server knows we're running the correct game and can reject the client // with a meaningful message - Com_sprintf(data, sizeof(data), "getchallenge %d %s", clc.challenge, Cvar_VariableString("sv_heartbeat")); + Com_sprintf(data, sizeof(data), "getchallenge %d %s", clc.challenge, GAMENAME_FOR_SERVER); NET_OutOfBandPrint(NS_CLIENT, clc.serverAddress, "%s", data); break; @@ -3475,8 +3473,6 @@ // ~ and `, as keys and characters cl_consoleKeys = Cvar_Get( "cl_consoleKeys", "~ ` 0x7e 0x60", CVAR_ARCHIVE); - cl_gamename = Cvar_Get("cl_gamename", GAMENAME_FOR_MASTER, CVAR_TEMP); - // userinfo Cvar_Get ("name", "UnnamedPlayer", CVAR_USERINFO | CVAR_ARCHIVE ); Cvar_Get ("rate", "25000", CVAR_USERINFO | CVAR_ARCHIVE ); @@ -3699,9 +3695,24 @@ char info[MAX_INFO_STRING]; char *infoString; int prot; + char *gamename; infoString = MSG_ReadString( msg ); + // if this isn't the correct gamename, ignore it + gamename = Info_ValueForKey( infoString, "gamename" ); + +#ifdef LEGACY_PROTOCOL + if ((com_legacyprotocol->integer && *gamename && strcmp(gamename, com_gamename->string)) + || (!com_legacyprotocol->integer && (!*gamename || strcmp(gamename, com_gamename->string)))) +#else + if (!*gamename || strcmp(gamename, com_gamename->string)) +#endif + { + Com_DPrintf( "Game mismatch in info packet: %s\n", infoString ); + return; + } + // if this isn't the correct protocol version, ignore it prot = atoi( Info_ValueForKey( infoString, "protocol" ) ); @@ -4083,16 +4094,17 @@ if(v4enabled) { Com_sprintf(command, sizeof(command), "getserversExt %s %s", - cl_gamename->string, Cmd_Argv(2)); + com_gamename->string, Cmd_Argv(2)); } else { Com_sprintf(command, sizeof(command), "getserversExt %s %s ipv6", - cl_gamename->string, Cmd_Argv(2)); + com_gamename->string, Cmd_Argv(2)); } } else - Com_sprintf(command, sizeof(command), "getservers %s", Cmd_Argv(2)); + Com_sprintf(command, sizeof(command), "getservers %s %s", + com_gamename->string, Cmd_Argv(2)); for (i=3; i < count; i++) {