From 0387b8002ef48831fd13475ad36e286370748011 Mon Sep 17 00:00:00 2001 From: Thilo Schulz Date: Sat, 5 Mar 2011 19:10:23 +0000 Subject: [PATCH] Add cvar "protocol" so user can change protocol version on command line, for standalone games. Most of the patch by Simon McVittie with a few minor modifications by myself --- README | 5 +++++ code/client/cl_main.c | 4 ++-- code/qcommon/common.c | 2 ++ code/qcommon/qcommon.h | 2 ++ code/server/sv_client.c | 4 ++-- code/server/sv_init.c | 1 - code/server/sv_main.c | 2 +- 7 files changed, 14 insertions(+), 6 deletions(-) diff --git a/README b/README index 27e56843..0481c739 100644 --- a/README +++ b/README @@ -113,6 +113,7 @@ New cvars cl_mouseAccelOffset - Tuning the acceleration curve, see below cl_gamename - Gamename sent to master server in getserversExt query + s_useOpenAL - use the OpenAL sound backend if available s_alPrecache - cache OpenAL sounds before use s_alGain - the value of AL_GAIN for each source @@ -155,6 +156,7 @@ New cvars com_maxfpsMinimized - Maximum frames per second when minimized com_busyWait - Will use a busy loop to wait for rendering next frame when set to non-zero value + in_joystickNo - select which joystick to use in_keyboardDebug - print keyboard debug info @@ -178,6 +180,9 @@ New cvars ipv6 servers on the local network net_mcastiface - outgoing interface to use for scan + protocol - Allow changing protocol version + (startup only) + r_allowResize - make window resizable (SDL only) r_ext_texture_filter_anisotropic - anisotropic texture filtering r_zProj - distance of observer camera to projection diff --git a/code/client/cl_main.c b/code/client/cl_main.c index 8004f218..0df770ed 100644 --- a/code/client/cl_main.c +++ b/code/client/cl_main.c @@ -2124,7 +2124,7 @@ void CL_CheckForResend( void ) { port = Cvar_VariableValue ("net_qport"); Q_strncpyz( info, Cvar_InfoString( CVAR_USERINFO ), sizeof( info ) ); - Info_SetValueForKey( info, "protocol", va("%i", PROTOCOL_VERSION ) ); + Info_SetValueForKey( info, "protocol", va("%i", com_protocol->integer ) ); Info_SetValueForKey( info, "qport", va("%i", port ) ); Info_SetValueForKey( info, "challenge", va("%i", clc.challenge ) ); @@ -3405,7 +3405,7 @@ void CL_ServerInfoPacket( netadr_t from, msg_t *msg ) { // if this isn't the correct protocol version, ignore it prot = atoi( Info_ValueForKey( infoString, "protocol" ) ); - if ( prot != PROTOCOL_VERSION ) { + if ( prot != com_protocol->integer ) { Com_DPrintf( "Different protocol info packet: %s\n", infoString ); return; } diff --git a/code/qcommon/common.c b/code/qcommon/common.c index d397a1cf..0c7fd1bf 100644 --- a/code/qcommon/common.c +++ b/code/qcommon/common.c @@ -83,6 +83,7 @@ cvar_t *com_minimized; cvar_t *com_maxfpsMinimized; cvar_t *com_abnormalExit; cvar_t *com_standalone; +cvar_t *com_protocol; cvar_t *com_basegame; cvar_t *com_homepath; cvar_t *com_busyWait; @@ -2705,6 +2706,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 ); + com_protocol = Cvar_Get ("protocol", va("%i", PROTOCOL_VERSION), CVAR_SERVERINFO | CVAR_INIT); Sys_Init(); diff --git a/code/qcommon/qcommon.h b/code/qcommon/qcommon.h index a9a8b565..973499f3 100644 --- a/code/qcommon/qcommon.h +++ b/code/qcommon/qcommon.h @@ -848,6 +848,8 @@ extern cvar_t *sv_paused; extern cvar_t *cl_packetdelay; extern cvar_t *sv_packetdelay; +extern cvar_t *com_protocol; + // com_speeds times extern int time_game; extern int time_frontend; diff --git a/code/server/sv_client.c b/code/server/sv_client.c index 6461b3d8..614f0619 100644 --- a/code/server/sv_client.c +++ b/code/server/sv_client.c @@ -302,8 +302,8 @@ void SV_DirectConnect( netadr_t from ) { Q_strncpyz( userinfo, Cmd_Argv(1), sizeof(userinfo) ); version = atoi( Info_ValueForKey( userinfo, "protocol" ) ); - if ( version != PROTOCOL_VERSION ) { - NET_OutOfBandPrint( NS_SERVER, from, "print\nServer uses protocol version %i.\n", PROTOCOL_VERSION ); + if ( version != com_protocol->integer ) { + NET_OutOfBandPrint( NS_SERVER, from, "print\nServer uses protocol version %i (yours is %i).\n", com_protocol->integer, version ); Com_DPrintf (" rejected connect from version %i\n", version); return; } diff --git a/code/server/sv_init.c b/code/server/sv_init.c index 875961e4..39b06a09 100644 --- a/code/server/sv_init.c +++ b/code/server/sv_init.c @@ -636,7 +636,6 @@ void SV_Init (void) Cvar_Get ("timelimit", "0", CVAR_SERVERINFO); sv_gametype = Cvar_Get ("g_gametype", "0", CVAR_SERVERINFO | CVAR_LATCH ); Cvar_Get ("sv_keywords", "", CVAR_SERVERINFO); - Cvar_Get ("protocol", va("%i", PROTOCOL_VERSION), CVAR_SERVERINFO | CVAR_ROM); sv_mapname = Cvar_Get ("mapname", "nomap", CVAR_SERVERINFO | CVAR_ROM); sv_privateClients = Cvar_Get ("sv_privateClients", "0", CVAR_SERVERINFO); sv_hostname = Cvar_Get ("sv_hostname", "noname", CVAR_SERVERINFO | CVAR_ARCHIVE ); diff --git a/code/server/sv_main.c b/code/server/sv_main.c index 01411cb1..e35ec676 100644 --- a/code/server/sv_main.c +++ b/code/server/sv_main.c @@ -638,7 +638,7 @@ void SVC_Info( netadr_t from ) { // to prevent timed spoofed reply packets that add ghost servers Info_SetValueForKey( infostring, "challenge", Cmd_Argv(1) ); - Info_SetValueForKey( infostring, "protocol", va("%i", PROTOCOL_VERSION) ); + Info_SetValueForKey( infostring, "protocol", va("%i", com_protocol->integer) ); Info_SetValueForKey( infostring, "hostname", sv_hostname->string ); Info_SetValueForKey( infostring, "mapname", sv_mapname->string ); Info_SetValueForKey( infostring, "clients", va("%i", count) );