foxygit / doom Log in
commit 6a51ab4fdfcb3a606310cbc1c26e3a81bab510be
Author:     Simon Howard <fraggle@soulsphere.org>
AuthorDate: Sun Oct 22 18:54:50 2017 -0400
Commit:     Simon Howard <fraggle@soulsphere.org>
CommitDate: Sun Oct 22 18:54:50 2017 -0400

    setup: Tweak server list interface.

    When finding a server to join it helps to know if other players are
    already connected. So include a player count, but because of the limited
    screen space, only if there already are players. Also fix the
    capitalization of the word "Internet".

    This fixes #907. Thanks to @JNechaevsky for the report.
---
 src/setup/multiplayer.c | 19 ++++++++++++++++---
 1 file changed, 16 insertions(+), 3 deletions(-)

diff --git a/src/setup/multiplayer.c b/src/setup/multiplayer.c
index d1d1ba39..a8550eeb 100644
--- a/src/setup/multiplayer.c
+++ b/src/setup/multiplayer.c
@@ -933,8 +933,21 @@ static void QueryResponseCallback(net_addr_t *addr,
     }

     M_snprintf(ping_time_str, sizeof(ping_time_str), "%ims", ping_time);
-    M_StringCopy(description, querydata->description,
-                 sizeof(description));
+
+    // Build description from server name field. Because there is limited
+    // space, we only include the player count if there are already players
+    // connected to the server.
+    if (querydata->num_players > 0)
+    {
+        M_snprintf(description, sizeof(description), "(%d/%d) ",
+                   querydata->num_players, querydata->max_players);
+    }
+    else
+    {
+        M_StringCopy(description, "", sizeof(description));
+    }
+
+    M_StringConcat(description, querydata->description, sizeof(description));

     TXT_AddWidgets(results_table,
                    TXT_NewLabel(ping_time_str),
@@ -992,7 +1005,7 @@ static void FindInternetServer(TXT_UNCAST_ARG(widget),
                                TXT_UNCAST_ARG(user_data))
 {
     NET_StartMasterQuery();
-    ServerQueryWindow("Find internet server");
+    ServerQueryWindow("Find Internet server");
 }

 static void FindLANServer(TXT_UNCAST_ARG(widget),