From 0a6f8739998d56563341f8b6c87066bf3b8163b7 Mon Sep 17 00:00:00 2001 From: Thilo Schulz Date: Mon, 7 Mar 2011 23:12:16 +0000 Subject: [PATCH] Add g_humansplayers (found by server) and g_needpass (cvar) to serverinfo (#4702) --- code/client/cl_main.c | 4 ++++ code/client/cl_ui.c | 2 ++ code/client/client.h | 2 ++ code/server/sv_main.c | 9 +++++++-- 4 files changed, 15 insertions(+), 2 deletions(-) diff --git a/code/client/cl_main.c b/code/client/cl_main.c index c0b2deec..021388af 100644 --- a/code/client/cl_main.c +++ b/code/client/cl_main.c @@ -3382,6 +3382,8 @@ static void CL_SetServerInfo(serverInfo_t *server, const char *info, int ping) { server->minPing = atoi(Info_ValueForKey(info, "minping")); server->maxPing = atoi(Info_ValueForKey(info, "maxping")); server->punkbuster = atoi(Info_ValueForKey(info, "punkbuster")); + server->g_humanplayers = atoi(Info_ValueForKey(info, "g_humanplayers")); + server->g_needpass = atoi(Info_ValueForKey(info, "g_needpass")); } server->ping = ping; } @@ -3500,6 +3502,8 @@ void CL_ServerInfoPacket( netadr_t from, msg_t *msg ) { cls.localServers[i].gameType = 0; cls.localServers[i].netType = from.type; cls.localServers[i].punkbuster = 0; + cls.localServers[i].g_humanplayers = 0; + cls.localServers[i].g_needpass = 0; Q_strncpyz( info, MSG_ReadString( msg ), MAX_INFO_STRING ); if (strlen(info)) { diff --git a/code/client/cl_ui.c b/code/client/cl_ui.c index adda0db1..00857ed3 100644 --- a/code/client/cl_ui.c +++ b/code/client/cl_ui.c @@ -298,6 +298,8 @@ static void LAN_GetServerInfo( int source, int n, char *buf, int buflen ) { Info_SetValueForKey( info, "nettype", va("%i",server->netType)); Info_SetValueForKey( info, "addr", NET_AdrToStringwPort(server->adr)); Info_SetValueForKey( info, "punkbuster", va("%i", server->punkbuster)); + Info_SetValueForKey( info, "g_needpass", va("%i", server->g_needpass)); + Info_SetValueForKey( info, "g_humanplayers", va("%i", server->g_humanplayers)); Q_strncpyz(buf, info, buflen); } else { if (buf) { diff --git a/code/client/client.h b/code/client/client.h index 28ce120e..d24f0622 100644 --- a/code/client/client.h +++ b/code/client/client.h @@ -296,6 +296,8 @@ typedef struct { int ping; qboolean visible; int punkbuster; + int g_humanplayers; + int g_needpass; } serverInfo_t; typedef struct { diff --git a/code/server/sv_main.c b/code/server/sv_main.c index e35ec676..73402ee0 100644 --- a/code/server/sv_main.c +++ b/code/server/sv_main.c @@ -606,7 +606,7 @@ if a user is interested in a server to do a full status ================ */ void SVC_Info( netadr_t from ) { - int i, count; + int i, count, humans; char *gamedir; char infostring[MAX_INFO_STRING]; @@ -625,10 +625,13 @@ void SVC_Info( netadr_t from ) { return; // don't count privateclients - count = 0; + count = humans = 0; for ( i = sv_privateClients->integer ; i < sv_maxclients->integer ; i++ ) { if ( svs.clients[i].state >= CS_CONNECTED ) { count++; + if (svs.clients[i].netchan.remoteAddress.type != NA_BOT) { + humans++; + } } } @@ -642,10 +645,12 @@ void SVC_Info( netadr_t from ) { Info_SetValueForKey( infostring, "hostname", sv_hostname->string ); Info_SetValueForKey( infostring, "mapname", sv_mapname->string ); Info_SetValueForKey( infostring, "clients", va("%i", count) ); + Info_SetValueForKey( infostring, "g_humanplayers", va("%i", humans ) ); Info_SetValueForKey( infostring, "sv_maxclients", va("%i", sv_maxclients->integer - sv_privateClients->integer ) ); Info_SetValueForKey( infostring, "gametype", va("%i", sv_gametype->integer ) ); Info_SetValueForKey( infostring, "pure", va("%i", sv_pure->integer ) ); + Info_SetValueForKey( infostring, "g_needpass", Cvar_VariableIntegerValue( "g_needpass" )); #ifdef USE_VOIP if (sv_voip->integer) {