diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/client/cl_main.c | 77 | ||||
-rw-r--r-- | src/qcommon/common.c | 2 | ||||
-rw-r--r-- | src/qcommon/q_shared.h | 5 | ||||
-rw-r--r-- | src/qcommon/qcommon.h | 2 | ||||
-rw-r--r-- | src/server/server.h | 4 | ||||
-rw-r--r-- | src/server/sv_client.c | 4 | ||||
-rw-r--r-- | src/server/sv_init.c | 3 | ||||
-rw-r--r-- | src/server/sv_main.c | 12 |
8 files changed, 31 insertions, 78 deletions
diff --git a/src/client/cl_main.c b/src/client/cl_main.c index b9742649..a10b1444 100644 --- a/src/client/cl_main.c +++ b/src/client/cl_main.c @@ -111,8 +111,6 @@ cvar_t *cl_guidServerUniq; cvar_t *cl_consoleKeys; -cvar_t *cl_gamename; - clientActive_t cl; clientConnection_t clc; clientStatic_t cls; @@ -228,58 +226,6 @@ void CL_UpdateVoipGain(const char *idstr, float gain) } } -/* -================ -CL_VoipParseTargets - -Sets clc.voipTarget{1,2,3} by asking the cgame to produce a string and then -parsing it as a series of client numbers -Perhaps it would be better to allow the cgame to set the three integers -directly, but this way we can change the net protocol without changing the -vmcall -================ -*/ -static void CL_VoipParseTargets( void ) -{ - const char *target = cl_voipSendTarget->string; - intptr_t p = VM_Call( cgvm, CG_VOIP_STRING ); - - if( p ) - target = VM_ExplicitArgPtr( cgvm, p ); - - if( !target[ 0 ] || Q_stricmp( target, "all" ) == 0 ) - clc.voipTarget1 = clc.voipTarget2 = clc.voipTarget3 = 0x7FFFFFFF; - else if( Q_stricmp( target, "none" ) == 0 ) - clc.voipTarget1 = clc.voipTarget2 = clc.voipTarget3 = 0; - else - { - char *end; - int val; - clc.voipTarget1 = clc.voipTarget2 = clc.voipTarget3 = 0; - - while( 1 ) - { - while( *target && !isdigit( *target ) ) - target++; - if( !*target ) - break; - - val = strtol( target, &end, 10 ); - assert( target != end ); - if( val < 0 || val >= MAX_CLIENTS ) - Com_Printf( S_COLOR_YELLOW "WARNING: VoIP target %d is not a valid " - "client number\n", val ); - else if( val < 31 ) - clc.voipTarget1 |= 1 << val; - else if( ( val -= 31 ) < 31 ) - clc.voipTarget2 |= 1 << val; - else if( ( val -= 31 ) < 31 ) - clc.voipTarget3 |= 1 << val; - target = end; - } - } -} - void CL_Voip_f( void ) { const char *cmd = Cmd_Argv(1); @@ -2369,9 +2315,9 @@ void CL_CheckForResend( void ) { // requesting a challenge // 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 or 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, com_gamename->string); NET_OutOfBandPrint(NS_CLIENT, clc.serverAddress, "%s", data); break; @@ -3597,8 +3543,6 @@ void CL_Init( void ) { // ~ 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", Sys_GetCurrentUser( ), CVAR_USERINFO | CVAR_ARCHIVE ); Cvar_Get ("rate", "25000", CVAR_USERINFO | CVAR_ARCHIVE ); @@ -3812,9 +3756,19 @@ void CL_ServerInfoPacket( netadr_t from, msg_t *msg ) { 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" ); + + if (gamename && *gamename && strcmp(gamename, com_gamename->string)) + { + 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" ) ); if ( prot != PROTOCOL_VERSION ) { @@ -4185,16 +4139,17 @@ void CL_GlobalServers_f( void ) { 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++) { diff --git a/src/qcommon/common.c b/src/qcommon/common.c index 3127dec1..5589b384 100644 --- a/src/qcommon/common.c +++ b/src/qcommon/common.c @@ -84,6 +84,7 @@ cvar_t *com_maxfpsUnfocused; cvar_t *com_minimized; cvar_t *com_maxfpsMinimized; cvar_t *com_abnormalExit; +cvar_t *com_gamename; cvar_t *com_homepath; cvar_t *com_busyWait; @@ -2661,6 +2662,7 @@ void Com_Init( char *commandLine ) { s = va("%s %s %s", Q3_VERSION, PLATFORM_STRING, __DATE__ ); com_version = Cvar_Get ("version", s, CVAR_ROM | CVAR_SERVERINFO ); Cvar_Get ("protocol", va("%i", PROTOCOL_VERSION), CVAR_SERVERINFO | CVAR_ROM); + com_gamename = Cvar_Get("com_gamename", GAMENAME_FOR_MASTER, CVAR_SERVERINFO | CVAR_INIT); Sys_Init(); diff --git a/src/qcommon/q_shared.h b/src/qcommon/q_shared.h index 189d1751..51e3b220 100644 --- a/src/qcommon/q_shared.h +++ b/src/qcommon/q_shared.h @@ -38,12 +38,13 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA #define Q3_VERSION PRODUCT_NAME " " PRODUCT_VERSION #define GAMENAME_FOR_MASTER "Tremulous" -#define HEARTBEAT_FOR_MASTER GAMENAME_FOR_MASTER -#define FLATLINE_FOR_MASTER GAMENAME_FOR_MASTER "dead" #define HOMEPATH_NAME_UNIX ".tremulous" #define HOMEPATH_NAME_WIN "Tremulous" #define HOMEPATH_NAME_MACOSX HOMEPATH_NAME_WIN +// Heartbeat for dpmaster protocol. You shouldn't change this unless you know what you're doing +#define HEARTBEAT_FOR_MASTER "DarkPlaces" + #define MAX_TEAMNAME 32 #define MAX_MASTER_SERVERS 5 // number of supported master servers diff --git a/src/qcommon/qcommon.h b/src/qcommon/qcommon.h index ead93b15..275fb4a5 100644 --- a/src/qcommon/qcommon.h +++ b/src/qcommon/qcommon.h @@ -846,6 +846,8 @@ extern cvar_t *sv_paused; extern cvar_t *cl_packetdelay; extern cvar_t *sv_packetdelay; +extern cvar_t *com_gamename; + // com_speeds times extern int time_game; extern int time_frontend; diff --git a/src/server/server.h b/src/server/server.h index de4ecc27..f97782f3 100644 --- a/src/server/server.h +++ b/src/server/server.h @@ -281,9 +281,7 @@ extern cvar_t *sv_minPing; extern cvar_t *sv_maxPing; extern cvar_t *sv_pure; extern cvar_t *sv_lanForceRate; -extern cvar_t *sv_dequeuePeriod; -extern cvar_t *sv_heartbeat; -extern cvar_t *sv_flatline; +extern cvar_t *sv_banFile; #ifdef USE_VOIP extern cvar_t *sv_voip; diff --git a/src/server/sv_client.c b/src/server/sv_client.c index 094ed98f..f3d190de 100644 --- a/src/server/sv_client.c +++ b/src/server/sv_client.c @@ -66,10 +66,10 @@ void SV_GetChallenge(netadr_t from) if(gameName && *gameName) { // reject client if the heartbeat string sent by the client doesn't match ours - if(strcmp(gameName, sv_heartbeat->string)) + if(strcmp(gameName, com_gamename->string)) { NET_OutOfBandPrint(NS_SERVER, from, "print\nGame mismatch: This is a %s server\n", - sv_heartbeat->string); + com_gamename->string); return; } } diff --git a/src/server/sv_init.c b/src/server/sv_init.c index d2326db5..45c87895 100644 --- a/src/server/sv_init.c +++ b/src/server/sv_init.c @@ -671,9 +671,6 @@ void SV_Init (void) sv_killserver = Cvar_Get ("sv_killserver", "0", 0); sv_mapChecksum = Cvar_Get ("sv_mapChecksum", "", CVAR_ROM); sv_lanForceRate = Cvar_Get ("sv_lanForceRate", "1", CVAR_ARCHIVE ); - sv_dequeuePeriod = Cvar_Get ("sv_dequeuePeriod", "500", CVAR_ARCHIVE ); - sv_heartbeat = Cvar_Get("sv_heartbeat", HEARTBEAT_FOR_MASTER, CVAR_INIT); - sv_flatline = Cvar_Get("sv_flatline", FLATLINE_FOR_MASTER, CVAR_INIT); } diff --git a/src/server/sv_main.c b/src/server/sv_main.c index fdd7127b..c6ee8304 100644 --- a/src/server/sv_main.c +++ b/src/server/sv_main.c @@ -56,10 +56,7 @@ cvar_t *sv_minPing; cvar_t *sv_maxPing; cvar_t *sv_pure; cvar_t *sv_lanForceRate; // dedicated 1 (LAN) server forces local client rates to 99999 (bug #491) -cvar_t *sv_dequeuePeriod; -cvar_t *sv_heartbeat; // Heartbeat string that is sent to the master -cvar_t *sv_flatline; // If the master server supports it we can send a flatline - // when server is killed +cvar_t *sv_banFile; /* ============================================================================= @@ -323,11 +320,11 @@ Informs all masters that this server is going down void SV_MasterShutdown( void ) { // send a hearbeat right now svs.nextHeartbeatTime = -9999; - SV_MasterHeartbeat(sv_flatline->string); + SV_MasterHeartbeat(HEARTBEAT_FOR_MASTER); // send it again to minimize chance of drops svs.nextHeartbeatTime = -9999; - SV_MasterHeartbeat(sv_flatline->string); + SV_MasterHeartbeat(HEARTBEAT_FOR_MASTER); // when the master tries to poll the server, it won't respond, so // it will be removed from the list @@ -649,6 +646,7 @@ void SVC_Info( netadr_t from ) { Info_SetValueForKey( infostring, "challenge", Cmd_Argv(1) ); Info_SetValueForKey( infostring, "protocol", va("%i", PROTOCOL_VERSION) ); + Info_SetValueForKey( infostring, "gamename", com_gamename->string ); Info_SetValueForKey( infostring, "hostname", sv_hostname->string ); Info_SetValueForKey( infostring, "mapname", sv_mapname->string ); Info_SetValueForKey( infostring, "clients", va("%i", count) ); @@ -1137,7 +1135,7 @@ void SV_Frame( int msec ) { SV_SendClientMessages(); // send a heartbeat to the master if needed - SV_MasterHeartbeat(sv_heartbeat->string); + SV_MasterHeartbeat(HEARTBEAT_FOR_MASTER); } /* |