From fc6ff9374d17e46effa3a2f4c7cf39eec5c8d0db Mon Sep 17 00:00:00 2001 From: Bill Currie Date: Wed, 4 Oct 2000 16:22:51 +0000 Subject: [PATCH] A solution to the problem of when to set the extended info keys. This allows for nice large amounts of client info to be sent to a QuakeForge server. sv_main.c: Append " QF" to the challenge reply. This DOES NOT break older clients because atoi stops parsing at the first non-number character but returns the value of what it successfully parsed. If a client does choke on this, its libc is broken and not to spec. cl_main.c: Check for "QF" in the challenge string and if it's there, set the QF extended info keys before connecting. Also, make sure the extended info keys are NOT set prior to starting the connect process. This is done is the CL_Disconnect function. --- source/cl_main.c | 50 +++++++++++++++++++++++++++++++++++------------- source/sv_main.c | 2 +- 2 files changed, 38 insertions(+), 14 deletions(-) diff --git a/source/cl_main.c b/source/cl_main.c index a563778..c074c1e 100644 --- a/source/cl_main.c +++ b/source/cl_main.c @@ -82,6 +82,7 @@ #include #endif +void CL_RemoveQFInfoKeys (); // we need to declare some mouse variables here, because the menu system // references them even when on a unix system. @@ -489,8 +490,7 @@ void CL_Disconnect (void) cls.demoplayback = cls.demorecording = cls.timedemo = false; - Info_RemoveKey (cls.userinfo, "*cap"); - Info_RemoveKey (cls.userinfo, "*qsg_version"); + CL_RemoveQFInfoKeys (); } Cam_Reset(); @@ -658,19 +658,41 @@ void CL_FullServerinfo_f (void) } else { allowskybox = false; } - if ((p = Info_ValueForKey (cl.serverinfo, "*qsg_version")) && *p) { - char cap[100] = ""; // max of 98 or so flags - // set the capabilities info. single char flags (possibly with - // modifiefs) - // defined capabilities: +} + +/* + + CL_AddQFInfoKeys + +*/ + +void +CL_AddQFInfoKeys () +{ + char cap[100] = ""; // max of 98 or so flags + // set the capabilities info. single char flags (possibly with + // modifiefs) + // defined capabilities: + // z client can accept gzipped files. #ifdef HAVE_ZLIB - // z client can accept gzipped files. - strcat (cap, "z"); + strcat (cap, "z"); #endif - Info_SetValueForStarKey (cls.userinfo, "*cap", cap, MAX_INFO_STRING); - Info_SetValueForStarKey (cls.userinfo, "*qsg_version", QSG_VERSION, - MAX_SERVERINFO_STRING); - } + Info_SetValueForStarKey (cls.userinfo, "*cap", cap, MAX_INFO_STRING); + Info_SetValueForStarKey (cls.userinfo, "*qsg_version", QSG_VERSION, + MAX_SERVERINFO_STRING); + Con_Printf ("QuakeForge server detected\n"); +} + +/* + + CL_RemoveQFInfoKeys + +*/ +void +CL_RemoveQFInfoKeys () +{ + Info_RemoveKey (cls.userinfo, "*cap"); + Info_RemoveKey (cls.userinfo, "*qsg_version"); } /* @@ -1004,6 +1026,8 @@ void CL_ConnectionlessPacket (void) s = MSG_ReadString (); cls.challenge = atoi(s); + if (strstr (s, "QF")) + CL_AddQFInfoKeys (); CL_SendConnectPacket (); return; } diff --git a/source/sv_main.c b/source/sv_main.c index 2b0e2aa..8d5968a 100644 --- a/source/sv_main.c +++ b/source/sv_main.c @@ -626,7 +626,7 @@ void SVC_GetChallenge (void) } // send it back - Netchan_OutOfBandPrint (net_from, "%c%i", S2C_CHALLENGE, + Netchan_OutOfBandPrint (net_from, "%c%i QF", S2C_CHALLENGE, svs.challenges[i].challenge); }