]> git.rm.cloudns.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Display minplayers and maxplayers in welcome message
authorbones_was_here <bones_was_here@xonotic.au>
Mon, 26 Sep 2022 05:22:05 +0000 (15:22 +1000)
committerbones_was_here <bones_was_here@xonotic.au>
Mon, 26 Sep 2022 05:22:05 +0000 (15:22 +1000)
These are stored in globals as they will be read by HUD and scoreboard

qcsrc/client/main.qc
qcsrc/client/main.qh
qcsrc/server/client.qc

index b35b7f3db63b1c11717b0e919b0675c9c71d33df..eb4cb7ba87e7f2b1312210f0914417d347217b1c 100644 (file)
@@ -1423,6 +1423,8 @@ bool net_handle_ServerWelcome()
        string hostversion = ReadString();
        bool version_mismatch = ReadByte();
        bool version_check = ReadByte();
+       srv_minplayers = ReadByte();
+       srv_maxplayers = ReadByte();
        string modifications = translate_modifications(ReadString());
        string weaponarena_list = translate_weaponarena(ReadString());
        string cache_mutatormsg = ReadString();
@@ -1432,6 +1434,19 @@ bool net_handle_ServerWelcome()
 
        msg = strcat(msg, "^8\n\n", strcat(_("Gametype:"), " ^1", MapInfo_Type_ToText(gametype)), "^8\n");
 
+       if (srv_minplayers || srv_maxplayers)
+       {
+               msg = strcat(msg, "^8\n", _("This match supports"), " ^5");
+               if (srv_minplayers == srv_maxplayers)
+                       msg = strcat(msg, sprintf(_("%d players"), srv_maxplayers), "^8\n");
+               else if (srv_minplayers && srv_maxplayers)
+                       msg = strcat(msg, sprintf(_("%d to %d players"), srv_minplayers, srv_maxplayers), "^8\n");
+               else if (srv_maxplayers)
+                       msg = strcat(msg, sprintf(_("%d players maximum"), srv_maxplayers), "^8\n");
+               else
+                       msg = strcat(msg, sprintf(_("%d players minimum"), srv_minplayers), "^8\n");
+       }
+
        modifications = cons_mid(modifications, ", ", weaponarena_list);
        if(modifications != "")
                msg = strcat(msg, "^8\n", _("Active modifications:"), " ^3", modifications, "^8\n");
index 4726fe8ad6c3bb3fb42ff27108e4ba6e57db7c59..bc16e202ecdf1da2d60e712ea8afd9ff9eae02b0 100644 (file)
@@ -105,6 +105,8 @@ bool warmup_stage;
 
 string hostname;
 string welcome_msg;
+int srv_minplayers;
+int srv_maxplayers;
 float welcome_msg_menu_check_maxtime;
 void Welcome_Message_Show_Try();
 
index f3ef104a9f54106b650e6fc29d37552541a47794..b60ae7863f5b61730593ecf499e81cae56579c36 100644 (file)
@@ -1040,6 +1040,8 @@ void SendWelcomeMessage(entity this, int msg_type)
        WriteString(msg_type, autocvar_g_xonoticversion);
        WriteByte(msg_type, CS(this).version_mismatch);
        WriteByte(msg_type, (CS(this).version < autocvar_gameversion));
+       WriteByte(msg_type, map_minplayers);
+       WriteByte(msg_type, GetPlayerLimit());
 
        MUTATOR_CALLHOOK(BuildMutatorsPrettyString, "");
        string modifications = M_ARGV(0, string);