engine: client: more reliable way to find the payload the netinfo response

This commit is contained in:
Alibek Omarov 2024-07-07 06:49:54 +03:00
parent ab130ee92c
commit e0dc1eec93

View file

@ -1868,6 +1868,7 @@ static void CL_ParseNETInfoMessage( netadr_t from, const char *s )
int i, context, type; int i, context, type;
int errorBits = 0; int errorBits = 0;
const char *val; const char *val;
size_t slen;
context = Q_atoi( Cmd_Argv( 1 )); context = Q_atoi( Cmd_Argv( 1 ));
type = Q_atoi( Cmd_Argv( 2 )); type = Q_atoi( Cmd_Argv( 2 ));
@ -1886,23 +1887,45 @@ static void CL_ParseNETInfoMessage( netadr_t from, const char *s )
if( nr == NULL ) if( nr == NULL )
return; return;
// find the infostring // find the payload
while( *s != '\\' && *s ) s = Q_strchr( s, ' ' ); // skip netinfo
s++; if( !s )
return;
if( s[0] == '\\' ) s = Q_strchr( s + 1, ' ' ); // skip challenge
if( !s )
return;
s = Q_strchr( s + 1, ' ' ); // skip type
if( s )
s++; // skip final whitespace
else if( type != NETAPI_REQUEST_PING ) // ping have no payload, and that's ok
return;
if( s )
{ {
// check for errors if( s[0] == '\\' )
val = Info_ValueForKey( s, "neterror" ); {
// check for errors
val = Info_ValueForKey( s, "neterror" );
if( !Q_stricmp( val, "protocol" )) if( !Q_stricmp( val, "protocol" ))
SetBits( errorBits, NET_ERROR_PROTO_UNSUPPORTED ); SetBits( errorBits, NET_ERROR_PROTO_UNSUPPORTED );
else if( !Q_stricmp( val, "undefined" )) else if( !Q_stricmp( val, "undefined" ))
SetBits( errorBits, NET_ERROR_UNDEFINED ); SetBits( errorBits, NET_ERROR_UNDEFINED );
else if( !Q_stricmp( val, "forbidden" )) else if( !Q_stricmp( val, "forbidden" ))
SetBits( errorBits, NET_ERROR_FORBIDDEN ); SetBits( errorBits, NET_ERROR_FORBIDDEN );
CL_FixupColorStringsForInfoString( s, infostring, sizeof( infostring )); CL_FixupColorStringsForInfoString( s, infostring, sizeof( infostring ));
}
else
{
Q_strncpy( infostring, s, sizeof( infostring ));
}
}
else
{
infostring[0] = 0;
} }
// setup the answer // setup the answer