]> git.xonotic.org Git - xonotic/darkplaces.git/commitdiff
compare the right values for host cache masks;
authordivverent <divverent@d7cf8633-e32d-0410-b094-e92efae38249>
Fri, 20 Apr 2007 15:59:28 +0000 (15:59 +0000)
committerdivverent <divverent@d7cf8633-e32d-0410-b094-e92efae38249>
Fri, 20 Apr 2007 15:59:28 +0000 (15:59 +0000)
use -1 bots to indicate unknown bot count

git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@7146 d7cf8633-e32d-0410-b094-e92efae38249

netconn.c

index 98731232ce05def3b72a3cee5933adb1c21a2b90..b23d9f4784b878d7503c167f3a02bf3320884831 100755 (executable)
--- a/netconn.c
+++ b/netconn.c
@@ -291,9 +291,9 @@ static qboolean _ServerList_Entry_Mask( serverlist_mask_t *mask, serverlist_info
                return false;
        if( !_ServerList_CompareInt( info->numplayers, mask->tests[SLIF_NUMPLAYERS], mask->info.numplayers ) )
                return false;
-       if( !_ServerList_CompareInt( info->numplayers, mask->tests[SLIF_NUMBOTS], mask->info.numbots ) )
+       if( !_ServerList_CompareInt( info->numbots, mask->tests[SLIF_NUMBOTS], mask->info.numbots ) )
                return false;
-       if( !_ServerList_CompareInt( info->numplayers, mask->tests[SLIF_NUMHUMANS], mask->info.numhumans ) )
+       if( !_ServerList_CompareInt( info->numhumans, mask->tests[SLIF_NUMHUMANS], mask->info.numhumans ) )
                return false;
        if( !_ServerList_CompareInt( info->protocol, mask->tests[SLIF_PROTOCOL], mask->info.protocol ))
                return false;
@@ -392,8 +392,15 @@ void ServerList_RebuildViewList(void)
 
 void ServerList_ResetMasks(void)
 {
+       int i;
+
        memset( &serverlist_andmasks, 0, sizeof( serverlist_andmasks ) );
        memset( &serverlist_ormasks, 0, sizeof( serverlist_ormasks ) );
+       // numbots needs to be compared to -1 to always succeed
+       for(i = 0; i < SERVERLIST_ANDMASKCOUNT; ++i)
+               serverlist_andmasks[i].info.numbots = -1;
+       for(i = 0; i < SERVERLIST_ORMASKCOUNT; ++i)
+               serverlist_ormasks[i].info.numbots = -1;
 }
 
 #if 0
@@ -1319,7 +1326,7 @@ static int NetConn_ClientParsePacket(lhnetsocket_t *mysocket, unsigned char *dat
                        info->name[0] = 0;
                        info->protocol = -1;
                        info->numplayers = 0;
-                       info->numbots = 0;
+                       info->numbots = -1;
                        info->maxplayers  = 0;
                        info->gameversion = 0;
                        if ((s = SearchInfostring(string, "gamename"     )) != NULL) strlcpy(info->game, s, sizeof (info->game));
@@ -1331,7 +1338,7 @@ static int NetConn_ClientParsePacket(lhnetsocket_t *mysocket, unsigned char *dat
                        if ((s = SearchInfostring(string, "bots"         )) != NULL) info->numbots = atoi(s);
                        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 - info->numbots;
+                       info->numhumans = info->numplayers - max(0, info->numbots);
 
                        NetConn_ClientParsePacket_ServerList_UpdateCache(n);