From fc5fe8b95af8c3e314abe62dc0727e5bd2efa04a Mon Sep 17 00:00:00 2001 From: divverent Date: Mon, 5 Nov 2007 13:39:06 +0000 Subject: [PATCH] add a "freeslots" field to the host cache git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@7661 d7cf8633-e32d-0410-b094-e92efae38249 --- mvm_cmds.c | 8 ++++++++ netconn.c | 6 ++++++ netconn.h | 5 ++++- 3 files changed, 18 insertions(+), 1 deletion(-) diff --git a/mvm_cmds.c b/mvm_cmds.c index 0c68542f..594fdedc 100644 --- a/mvm_cmds.c +++ b/mvm_cmds.c @@ -421,6 +421,9 @@ void VM_M_setserverlistmasknumber( void ) case SLIF_PROTOCOL: mask->info.protocol = number; break; + case SLIF_FREESLOTS: + mask->info.freeslots = number; + break; default: VM_Warning( "VM_M_setserverlistmasknumber: Bad field number %i passed!\n", field ); return; @@ -533,6 +536,9 @@ void VM_M_getserverlistnumber(void) case SLIF_NUMHUMANS: PRVM_G_FLOAT( OFS_RETURN ) = cache->info.numhumans; break; + case SLIF_FREESLOTS: + PRVM_G_FLOAT( OFS_RETURN ) = cache->info.freeslots; + break; case SLIF_PING: PRVM_G_FLOAT( OFS_RETURN ) = cache->info.ping; break; @@ -607,6 +613,8 @@ void VM_M_getserverlistindexforkey( void ) PRVM_G_FLOAT( OFS_RETURN ) = SLIF_NUMBOTS; else if( !strcmp( key, "numhumans" ) ) PRVM_G_FLOAT( OFS_RETURN ) = SLIF_NUMHUMANS; + else if( !strcmp( key, "freeslots" ) ) + PRVM_G_FLOAT( OFS_RETURN ) = SLIF_FREESLOTS; else if( !strcmp( key, "protocol" ) ) PRVM_G_FLOAT( OFS_RETURN ) = SLIF_PROTOCOL; else diff --git a/netconn.c b/netconn.c index 6c420e52..8513eafe 100755 --- a/netconn.c +++ b/netconn.c @@ -191,6 +191,9 @@ static qboolean _ServerList_Entry_Compare( serverlist_entry_t *A, serverlist_ent case SLIF_NUMHUMANS: result = A->info.numhumans - B->info.numhumans; break; + case SLIF_FREESLOTS: + result = A->info.freeslots - B->info.freeslots; + break; case SLIF_PROTOCOL: result = A->info.protocol - B->info.protocol; break; @@ -296,6 +299,8 @@ static qboolean _ServerList_Entry_Mask( serverlist_mask_t *mask, serverlist_info return false; if( !_ServerList_CompareInt( info->numhumans, mask->tests[SLIF_NUMHUMANS], mask->info.numhumans ) ) return false; + if( !_ServerList_CompareInt( info->freeslots, mask->tests[SLIF_FREESLOTS], mask->info.freeslots ) ) + return false; if( !_ServerList_CompareInt( info->protocol, mask->tests[SLIF_PROTOCOL], mask->info.protocol )) return false; if( *mask->info.cname @@ -1347,6 +1352,7 @@ static int NetConn_ClientParsePacket(lhnetsocket_t *mysocket, unsigned char *dat if ((s = SearchInfostring(string, "sv_maxclients")) != NULL) info->maxplayers = atoi(s); if ((s = SearchInfostring(string, "gameversion" )) != NULL) info->gameversion = atoi(s); info->numhumans = info->numplayers - max(0, info->numbots); + info->freeslots = info->maxplayers - info->numplayers; NetConn_ClientParsePacket_ServerList_UpdateCache(n); diff --git a/netconn.h b/netconn.h index 63df6644..e04bdb5d 100755 --- a/netconn.h +++ b/netconn.h @@ -252,6 +252,8 @@ typedef struct serverlist_info_s int numbots; // number of currently connected players that are not bots int numhumans; + // number of free slots + int freeslots; // protocol version int protocol; // game data version @@ -273,7 +275,8 @@ typedef enum SLIF_PROTOCOL, SLIF_NUMBOTS, SLIF_NUMHUMANS, - SLIF_COUNT + SLIF_COUNT, + SLIF_FREESLOTS } serverlist_infofield_t; typedef enum -- 2.39.2