Sophie

Sophie

distrib > Fedora > 13 > x86_64 > by-pkgid > 08163ffb50475ea8ee1ba869af0dfe3e > files > 4

quake3-1.36-8.svn1802.fc13.src.rpm

From: Simon McVittie <smcv@debian.org>
Date: Fri, 6 Aug 2010 20:34:51 +0100
Subject: [PATCH] Allow protocol cvar to be changed on the command line

This allows an unmodified ioquake3 binary to run standalone games that
have the same underlying protocol, but change PROTOCOL_VERSION to reflect
incompatible changes to game content, such as OpenArena. For instance,
OpenArena >= 0.8.1 can use:

    ioquake3 +set protocol 71 [...]

Origin: vendor, Debian
Bug: http://bugzilla.icculus.org/show_bug.cgi?id=4698
Forwarded: yes
---
 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 +-
 6 files changed, 9 insertions(+), 6 deletions(-)

diff --git a/code/client/cl_main.c b/code/client/cl_main.c
index 2b4be3a..0ea6d7c 100644
--- a/code/client/cl_main.c
+++ b/code/client/cl_main.c
@@ -2121,7 +2121,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", sv_protocol->integer ) );
 		Info_SetValueForKey( info, "qport", va("%i", port ) );
 		Info_SetValueForKey( info, "challenge", va("%i", clc.challenge ) );
 		
@@ -3386,7 +3386,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 != sv_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 64ec51d..d6c0532 100644
--- a/code/qcommon/common.c
+++ b/code/qcommon/common.c
@@ -84,6 +84,7 @@ cvar_t	*com_minimized;
 cvar_t	*com_maxfpsMinimized;
 cvar_t	*com_abnormalExit;
 cvar_t	*com_standalone;
+cvar_t	*sv_protocol;
 
 // com_speeds times
 int		time_game;
@@ -2745,6 +2746,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 );
+	sv_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 c6a61e2..6698454 100644
--- a/code/qcommon/qcommon.h
+++ b/code/qcommon/qcommon.h
@@ -839,6 +839,8 @@ extern	cvar_t	*sv_paused;
 extern	cvar_t	*cl_packetdelay;
 extern	cvar_t	*sv_packetdelay;
 
+extern	cvar_t	*sv_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 1195c88..657c936 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 != sv_protocol->integer ) {
+		NET_OutOfBandPrint( NS_SERVER, from, "print\nServer uses protocol version %i (yours is %i).\n", sv_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 bac7fa4..07f11d1 100644
--- a/code/server/sv_init.c
+++ b/code/server/sv_init.c
@@ -633,7 +633,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 67d7d51..9f20128 100644
--- a/code/server/sv_main.c
+++ b/code/server/sv_main.c
@@ -634,7 +634,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", sv_protocol->integer) );
 	Info_SetValueForKey( infostring, "hostname", sv_hostname->string );
 	Info_SetValueForKey( infostring, "mapname", sv_mapname->string );
 	Info_SetValueForKey( infostring, "clients", va("%i", count) );
--