Add g_humansplayers (found by server) and g_needpass (cvar) to serverinfo (#4702)

This commit is contained in:
Thilo Schulz 2011-03-07 23:12:16 +00:00
parent 97ed3650d7
commit 0a6f873999
4 changed files with 15 additions and 2 deletions

View File

@ -3382,6 +3382,8 @@ static void CL_SetServerInfo(serverInfo_t *server, const char *info, int ping) {
server->minPing = atoi(Info_ValueForKey(info, "minping")); server->minPing = atoi(Info_ValueForKey(info, "minping"));
server->maxPing = atoi(Info_ValueForKey(info, "maxping")); server->maxPing = atoi(Info_ValueForKey(info, "maxping"));
server->punkbuster = atoi(Info_ValueForKey(info, "punkbuster")); 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; server->ping = ping;
} }
@ -3500,6 +3502,8 @@ void CL_ServerInfoPacket( netadr_t from, msg_t *msg ) {
cls.localServers[i].gameType = 0; cls.localServers[i].gameType = 0;
cls.localServers[i].netType = from.type; cls.localServers[i].netType = from.type;
cls.localServers[i].punkbuster = 0; 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 ); Q_strncpyz( info, MSG_ReadString( msg ), MAX_INFO_STRING );
if (strlen(info)) { if (strlen(info)) {

View File

@ -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, "nettype", va("%i",server->netType));
Info_SetValueForKey( info, "addr", NET_AdrToStringwPort(server->adr)); Info_SetValueForKey( info, "addr", NET_AdrToStringwPort(server->adr));
Info_SetValueForKey( info, "punkbuster", va("%i", server->punkbuster)); 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); Q_strncpyz(buf, info, buflen);
} else { } else {
if (buf) { if (buf) {

View File

@ -296,6 +296,8 @@ typedef struct {
int ping; int ping;
qboolean visible; qboolean visible;
int punkbuster; int punkbuster;
int g_humanplayers;
int g_needpass;
} serverInfo_t; } serverInfo_t;
typedef struct { typedef struct {

View File

@ -606,7 +606,7 @@ if a user is interested in a server to do a full status
================ ================
*/ */
void SVC_Info( netadr_t from ) { void SVC_Info( netadr_t from ) {
int i, count; int i, count, humans;
char *gamedir; char *gamedir;
char infostring[MAX_INFO_STRING]; char infostring[MAX_INFO_STRING];
@ -625,10 +625,13 @@ void SVC_Info( netadr_t from ) {
return; return;
// don't count privateclients // don't count privateclients
count = 0; count = humans = 0;
for ( i = sv_privateClients->integer ; i < sv_maxclients->integer ; i++ ) { for ( i = sv_privateClients->integer ; i < sv_maxclients->integer ; i++ ) {
if ( svs.clients[i].state >= CS_CONNECTED ) { if ( svs.clients[i].state >= CS_CONNECTED ) {
count++; 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, "hostname", sv_hostname->string );
Info_SetValueForKey( infostring, "mapname", sv_mapname->string ); Info_SetValueForKey( infostring, "mapname", sv_mapname->string );
Info_SetValueForKey( infostring, "clients", va("%i", count) ); Info_SetValueForKey( infostring, "clients", va("%i", count) );
Info_SetValueForKey( infostring, "g_humanplayers", va("%i", humans ) );
Info_SetValueForKey( infostring, "sv_maxclients", Info_SetValueForKey( infostring, "sv_maxclients",
va("%i", sv_maxclients->integer - sv_privateClients->integer ) ); va("%i", sv_maxclients->integer - sv_privateClients->integer ) );
Info_SetValueForKey( infostring, "gametype", va("%i", sv_gametype->integer ) ); Info_SetValueForKey( infostring, "gametype", va("%i", sv_gametype->integer ) );
Info_SetValueForKey( infostring, "pure", va("%i", sv_pure->integer ) ); Info_SetValueForKey( infostring, "pure", va("%i", sv_pure->integer ) );
Info_SetValueForKey( infostring, "g_needpass", Cvar_VariableIntegerValue( "g_needpass" ));
#ifdef USE_VOIP #ifdef USE_VOIP
if (sv_voip->integer) { if (sv_voip->integer) {