Skip to content

Commit

Permalink
engine: client: more reliable way to find the payload the netinfo res…
Browse files Browse the repository at this point in the history
…ponse
  • Loading branch information
a1batross committed Jul 7, 2024
1 parent ab130ee commit e0dc1ee
Showing 1 changed file with 36 additions and 13 deletions.
49 changes: 36 additions & 13 deletions engine/client/cl_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -1868,6 +1868,7 @@ static void CL_ParseNETInfoMessage( netadr_t from, const char *s )
int i, context, type;
int errorBits = 0;
const char *val;
size_t slen;

context = Q_atoi( Cmd_Argv( 1 ));
type = Q_atoi( Cmd_Argv( 2 ));
Expand All @@ -1886,23 +1887,45 @@ static void CL_ParseNETInfoMessage( netadr_t from, const char *s )
if( nr == NULL )
return;

// find the infostring
while( *s != '\\' && *s )
s++;
// find the payload
s = Q_strchr( s, ' ' ); // skip netinfo
if( !s )
return;

s = Q_strchr( s + 1, ' ' ); // skip challenge
if( !s )
return;

if( s[0] == '\\' )
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
val = Info_ValueForKey( s, "neterror" );
if( s[0] == '\\' )
{
// check for errors
val = Info_ValueForKey( s, "neterror" );

if( !Q_stricmp( val, "protocol" ))
SetBits( errorBits, NET_ERROR_PROTO_UNSUPPORTED );
else if( !Q_stricmp( val, "undefined" ))
SetBits( errorBits, NET_ERROR_UNDEFINED );
else if( !Q_stricmp( val, "forbidden" ))
SetBits( errorBits, NET_ERROR_FORBIDDEN );
if( !Q_stricmp( val, "protocol" ))
SetBits( errorBits, NET_ERROR_PROTO_UNSUPPORTED );
else if( !Q_stricmp( val, "undefined" ))
SetBits( errorBits, NET_ERROR_UNDEFINED );
else if( !Q_stricmp( val, "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
Expand Down

0 comments on commit e0dc1ee

Please sign in to comment.