]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
show number of free player slots in the rightclick dialog
authorRudolf Polzer <divverent@alientrap.org>
Fri, 28 Jan 2011 21:32:18 +0000 (22:32 +0100)
committerRudolf Polzer <divverent@alientrap.org>
Fri, 28 Jan 2011 21:32:18 +0000 (22:32 +0100)
qcsrc/menu/xonotic/dialog_multiplayer_join_serverinfo.c

index 3ae9f08381a81e2fc3d3bc7b33a416875d6ac4cc..d396e7bbcc747a449a2cd482c743ca5564b0d582 100644 (file)
@@ -56,7 +56,7 @@ void Join_Click(entity btn, entity me);
 #ifdef IMPLEMENTATION
 void XonoticServerInfoDialog_loadServerInfo(entity me, float i)
 {
 #ifdef IMPLEMENTATION
 void XonoticServerInfoDialog_loadServerInfo(entity me, float i)
 {
-       float m, pure, j, numh, maxp;
+       float m, pure, freeslots, j, numh, maxp, numb;
        string s, typestr, versionstr, k, v;
 
        if(me.currentServerName)
        string s, typestr, versionstr, k, v;
 
        if(me.currentServerName)
@@ -123,6 +123,7 @@ void XonoticServerInfoDialog_loadServerInfo(entity me, float i)
                typestr = argv(0);
                versionstr = argv(1);
        }
                typestr = argv(0);
                versionstr = argv(1);
        }
+       freeslots = -1;
        for(j = 2; j < m; ++j)
        {
                if(argv(j) == "")
        for(j = 2; j < m; ++j)
        {
                if(argv(j) == "")
@@ -131,6 +132,8 @@ void XonoticServerInfoDialog_loadServerInfo(entity me, float i)
                v = substring(argv(j), 1, -1);
                if(k == "P")
                        pure = stof(v);
                v = substring(argv(j), 1, -1);
                if(k == "P")
                        pure = stof(v);
+               else if(k == "S")
+                       freeslots = stof(v);
        }
 
        me.currentServerType = strzone(typestr);
        }
 
        me.currentServerType = strzone(typestr);
@@ -148,11 +151,14 @@ void XonoticServerInfoDialog_loadServerInfo(entity me, float i)
        numh = gethostcachenumber(SLIST_FIELD_NUMHUMANS, i);
        SLIST_FIELD_MAXPLAYERS = gethostcacheindexforkey("maxplayers");
        maxp = gethostcachenumber(SLIST_FIELD_MAXPLAYERS, i);
        numh = gethostcachenumber(SLIST_FIELD_NUMHUMANS, i);
        SLIST_FIELD_MAXPLAYERS = gethostcacheindexforkey("maxplayers");
        maxp = gethostcachenumber(SLIST_FIELD_MAXPLAYERS, i);
-       me.currentServerNumPlayers = strzone(sprintf(_("%d/%d"), numh, maxp));
+       SLIST_FIELD_NUMBOTS = gethostcacheindexforkey("numbots");
+       numb = gethostcachenumber(SLIST_FIELD_NUMBOTS, i);
+       if(freeslots < 0)
+               freeslots = maxp - numh - numb;
+       me.currentServerNumPlayers = strzone(sprintf(_("%d/%d, %d free player slots"), numh, maxp, freeslots));
        me.numPlayersLabel.setText(me.numPlayersLabel, me.currentServerNumPlayers);
 
        me.numPlayersLabel.setText(me.numPlayersLabel, me.currentServerNumPlayers);
 
-       SLIST_FIELD_NUMBOTS = gethostcacheindexforkey("numbots");
-       s = ftos(gethostcachenumber(SLIST_FIELD_NUMBOTS, i));
+       s = ftos(numb);
        me.currentServerNumBots = strzone(s);
        me.numBotsLabel.setText(me.numBotsLabel, me.currentServerNumBots);
 
        me.currentServerNumBots = strzone(s);
        me.numBotsLabel.setText(me.numBotsLabel, me.currentServerNumBots);