From: bones_was_here Date: Mon, 26 Sep 2022 05:22:05 +0000 (+1000) Subject: Display minplayers and maxplayers in welcome message X-Git-Tag: xonotic-v0.8.6~348^2~11 X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=bd2e33a64b1103fb25150fe93a62d2d152428839;p=xonotic%2Fxonotic-data.pk3dir.git Display minplayers and maxplayers in welcome message These are stored in globals as they will be read by HUD and scoreboard --- diff --git a/qcsrc/client/main.qc b/qcsrc/client/main.qc index b35b7f3db..eb4cb7ba8 100644 --- a/qcsrc/client/main.qc +++ b/qcsrc/client/main.qc @@ -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"); diff --git a/qcsrc/client/main.qh b/qcsrc/client/main.qh index 4726fe8ad..bc16e202e 100644 --- a/qcsrc/client/main.qh +++ b/qcsrc/client/main.qh @@ -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(); diff --git a/qcsrc/server/client.qc b/qcsrc/server/client.qc index f3ef104a9..b60ae7863 100644 --- a/qcsrc/server/client.qc +++ b/qcsrc/server/client.qc @@ -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);