Added handling for "print" command in cl_main.c->CL_ConnectionlessPacket() that changes cl_servertrick and reconnects when a known "wrong version" rejection message is received.

Changed wrong protocol rejection messaged in sv_main.c->SVC_DirectConnect() to send KMQuake2 version instead of just version number.
This commit is contained in:
Knightmare66 2021-03-18 05:35:26 -04:00
parent 5a1a138095
commit 20baf8e390
4 changed files with 32 additions and 2 deletions

View file

@ -1569,11 +1569,38 @@ void CL_ConnectionlessPacket (void)
Cbuf_AddText ("\n");
return;
}
// print command from somewhere
if (!strcmp(c, "print"))
{
char thisVersionRejMsg[64];
s = MSG_ReadString (&net_message);
Com_Printf ("%s", s);
// catch wrong version reply from server here
Com_sprintf (thisVersionRejMsg, sizeof(thisVersionRejMsg), "You need KMQuake2 version %4.2f to play on this server.", VERSION);
if ( strstr(s, "Server is version 3.19") || strstr(s, "Server is version 3.2") // stock Q2 3.19 / 3.2x rejection messages
|| strstr(s, "You need Quake II 3.19 or higher to play on this server.") // R1Q2
|| strstr(s, "Unsupported protocol version") || strstr(s, "You need Quake 2 version 3.19 or higher.") ) // Q2Pro
{
Cvar_SetInteger ("cl_servertrick", 1);
Com_Printf ("Wrong version reply received from server. Reconnecting as protocol version %i.\n", OLD_PROTOCOL_VERSION);
CL_Reconnect_f ();
}
else if ( strstr(s, thisVersionRejMsg) ) // Same version of KMQ2
{
Cvar_SetInteger ("cl_servertrick", 0);
Com_Printf ("Wrong version reply received from server. Reconnecting as protocol version %i.\n", PROTOCOL_VERSION);
CL_Reconnect_f ();
}
else if ( strstr(s, "Server is version") ) // don't keep going if unknown version
{
Com_Printf ("Unknown wrong version reply received from server. Disconnecting.\n");
SCR_EndLoadingPlaque ();
CL_Disconnect ();
}
return;
}

View file

@ -113,7 +113,7 @@ How To Run
mod's code to run, it must be compiled into a kmq2gamex86.dll (see end of file for
instructions).
To connect to standard Quake2 (protocol 34) servers, add
To ping info from and connect to standard Quake2 (protocol 34) servers, add
+set cl_servertrick 1

View file

@ -21,6 +21,8 @@ Changes as of v0.20 update 8:
- Added support for quake2:// URLs.
- Added client auto-reconnect with cl_servertrick set correspondingly when a known "wrong version" rejection message is received.
- Added cel shading support. Uses cvars r_celshading to enable, and r_celshading_width for line width (1-10).
- Added horizontal offset to third-person mode. Offset distance is controlled by cvar cg_thirdperson_offset.

View file

@ -399,7 +399,8 @@ void SVC_DirectConnect (void)
version = atoi(Cmd_Argv(1));
if (version != PROTOCOL_VERSION)
{
Netchan_OutOfBandPrint (NS_SERVER, adr, "print\nServer is version %4.2f.\n", VERSION);
// Netchan_OutOfBandPrint (NS_SERVER, adr, "print\nServer is version %4.2f.\n", VERSION);
Netchan_OutOfBandPrint (NS_SERVER, adr, "print\nYou need KMQuake2 version %4.2f to play on this server.\n", VERSION);
Com_DPrintf (" rejected connect from version %i\n", version);
return;
}