Browse Source

engine: client: carefully check legacy server response, check info string before passing it to UI

pull/2/head
Alibek Omarov 2 years ago
parent
commit
9d4fe707bb
  1. 29
      engine/client/cl_main.c

29
engine/client/cl_main.c

@ -302,7 +302,7 @@ static float CL_LerpPoint( void )
else if( server_frametime > 0.001f ) else if( server_frametime > 0.001f )
{ {
// automatic lerp (classic mode) // automatic lerp (classic mode)
frac = ( cl.time - cl.mtime[1] ) / server_frametime; frac = ( cl.time - cl.mtime[1] ) / server_frametime;
} }
#endif #endif
return frac; return frac;
@ -367,7 +367,7 @@ void CL_ComputeClientInterpolationAmount( usercmd_t *cmd )
min_interp = 1.0f / cl_updaterate->value; min_interp = 1.0f / cl_updaterate->value;
interpolation_time = CL_LerpInterval( ); interpolation_time = CL_LerpInterval( );
if( (cl_interp->value + epsilon) < min_interp ) if( (cl_interp->value + epsilon) < min_interp )
{ {
Con_Printf( "ex_interp forced up to %.1f msec\n", min_interp * 1000.f ); Con_Printf( "ex_interp forced up to %.1f msec\n", min_interp * 1000.f );
@ -1713,16 +1713,23 @@ void CL_ParseStatusMessage( netadr_t from, sizebuf_t *msg )
static char infostring[MAX_INFO_STRING+8]; static char infostring[MAX_INFO_STRING+8];
char *s = MSG_ReadString( msg ); char *s = MSG_ReadString( msg );
int i; int i;
const char *magic = ": wrong version\n";
size_t len = Q_strlen( s ), magiclen = Q_strlen( magic );
CL_FixupColorStringsForInfoString( s, infostring ); if( len >= magiclen && !Q_strcmp( s + len - magiclen, magic ))
if( Q_strstr( infostring, "wrong version" ) )
{ {
Netchan_OutOfBandPrint( NS_CLIENT, from, "info %i", PROTOCOL_LEGACY_VERSION ); Netchan_OutOfBandPrint( NS_CLIENT, from, "info %i", PROTOCOL_LEGACY_VERSION );
Con_Printf( "^1Server^7: %s, Info: %s\n", NET_AdrToString( from ), infostring );
return; return;
} }
if( !Info_IsValid( s ))
{
Con_Printf( "^1Server^7: %s, invalid infostring\n", NET_AdrToString( from ));
return;
}
CL_FixupColorStringsForInfoString( s, infostring );
if( !COM_CheckString( Info_ValueForKey( infostring, "gamedir" ))) if( !COM_CheckString( Info_ValueForKey( infostring, "gamedir" )))
{ {
Con_Printf( "^1Server^7: %s, Info: %s\n", NET_AdrToString( from ), infostring ); Con_Printf( "^1Server^7: %s, Info: %s\n", NET_AdrToString( from ), infostring );
@ -1732,11 +1739,13 @@ void CL_ParseStatusMessage( netadr_t from, sizebuf_t *msg )
if( !COM_CheckString( Info_ValueForKey( infostring, "p" ))) if( !COM_CheckString( Info_ValueForKey( infostring, "p" )))
{ {
Info_SetValueForKey( infostring, "legacy", "1", sizeof( infostring ) ); Info_SetValueForKey( infostring, "legacy", "1", sizeof( infostring ) );
Con_Print("Legacy: "); Con_Printf( "^3Server^7: %s, Game: %s\n", NET_AdrToString( from ), Info_ValueForKey( infostring, "gamedir" ));
}
else
{
// more info about servers
Con_Printf( "^2Server^7: %s, Game: %s\n", NET_AdrToString( from ), Info_ValueForKey( infostring, "gamedir" ));
} }
// more info about servers
Con_Printf( "^2Server^7: %s, Game: %s\n", NET_AdrToString( from ), Info_ValueForKey( infostring, "gamedir" ));
UI_AddServerToList( from, infostring ); UI_AddServerToList( from, infostring );
} }

Loading…
Cancel
Save