summaryrefslogtreecommitdiff
path: root/src/ui
diff options
context:
space:
mode:
Diffstat (limited to 'src/ui')
-rw-r--r--src/ui/ui_main.c40
1 files changed, 37 insertions, 3 deletions
diff --git a/src/ui/ui_main.c b/src/ui/ui_main.c
index c88363ce..15699991 100644
--- a/src/ui/ui_main.c
+++ b/src/ui/ui_main.c
@@ -267,20 +267,53 @@ void UI_DrawRect( float x, float y, float width, float height, float size, const
/*
==================
+UI_ServerInfoIsValid
+
+Return false if the infostring contains nonprinting characters,
+ or if the hostname is blank/undefined
+==================
+*/
+static qboolean UI_ServerInfoIsValid( char *info )
+{
+ char *c;
+ int len = 0;
+
+ for( c = info; *c; c++ )
+ {
+ if( !isprint( *c ) )
+ return qfalse;
+ }
+
+ for( c = Info_ValueForKey( info, "hostname" ); *c; c++ )
+ {
+ if( isgraph( *c ) )
+ len++;
+ }
+
+ if( len )
+ return qfalse;
+ else
+ return qtrue;
+}
+
+/*
+==================
UI_InsertServerIntoDisplayList
==================
*/
static void UI_InsertServerIntoDisplayList( int num, int position )
{
- int i;
+ int i;
static char info[MAX_STRING_CHARS];
if( position < 0 || position > uiInfo.serverStatus.numDisplayServers )
return;
-
trap_LAN_GetServerInfo( ui_netSource.integer, num, info, MAX_STRING_CHARS );
+ if( !UI_ServerInfoIsValid( info ) ) // don't list servers with invalid info
+ return;
+
uiInfo.serverStatus.numDisplayServers++;
for( i = uiInfo.serverStatus.numDisplayServers; i > position; i-- )
@@ -968,7 +1001,8 @@ static void UI_StopServerRefresh( void )
if( count - uiInfo.serverStatus.numDisplayServers > 0 )
{
- Com_Printf( "%d servers not listed due to packet loss or pings higher than %d\n",
+ Com_Printf( "%d servers not listed due to packet loss, invalid info,"
+ " or pings higher than %d\n",
count - uiInfo.serverStatus.numDisplayServers,
( int ) trap_Cvar_VariableValue( "cl_maxPing" ) );
}