]> git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Partially build the Welcome message in client code, allowing translating some parts...
authorterencehill <piuntn@gmail.com>
Tue, 22 Mar 2022 23:11:57 +0000 (00:11 +0100)
committerterencehill <piuntn@gmail.com>
Tue, 22 Mar 2022 23:11:57 +0000 (00:11 +0100)
qcsrc/client/main.qc
qcsrc/server/client.qc
qcsrc/server/command/cmd.qh

index 8d35ecc7de0d37c94758a5c55fa28771e805613f..5e04e7160eef5408b273e5554d9ca81b19c25c00 100644 (file)
@@ -1288,9 +1288,27 @@ NET_HANDLE(TE_CSQC_WEAPONCOMPLAIN, bool isNew)
 
 NET_HANDLE(TE_CSQC_SERVERINFO, bool isNew)
 {
+       bool force_centerprint = ReadByte();
        string hostname = ReadString();
-       string msg = ReadString();
-       if (!isdemo() && cvar("_menu_welcome_dialog_available") && autocvar_cl_welcome_in_menu_dialog)
+       string ver = ReadString();
+       string gamemode_name = ReadString();
+       string modifications = ReadString();
+       string cache_mutatormsg = ReadString();
+       string mutator_msg = ReadString();
+       string motd = ReadString();
+
+       string msg = "";
+       msg = strcat(msg, ver);
+       msg = strcat(msg, "^8\n\n", _("match type is "), " ^1", gamemode_name, "^8\n");
+       if(modifications != "")
+               msg = strcat(msg, "^8\n", _("active modifications:"), " ^3", modifications, "^8\n");
+       if (cache_mutatormsg != "")
+               msg = strcat(msg, "\n\n^8", _("special gameplay tips:"), " ^7", cache_mutatormsg);
+       msg = strcat(msg, mutator_msg); // trust that the mutator will do proper formatting
+       if (motd != "")
+               msg = strcat(msg, "\n\n^8", _("MOTD:"), " ^7", motd);
+
+       if (!force_centerprint && !isdemo() && cvar("_menu_welcome_dialog_available") && autocvar_cl_welcome_in_menu_dialog)
        {
                string welcomedialog_args;
                welcomedialog_args = strcat("HOSTNAME \"", hostname, "\"");
index 75c98a868972d499b59411cec10a5742e51d19b4..cadb523cf1af33c0f60b834014b11da8377543ef 100644 (file)
@@ -1033,8 +1033,15 @@ string GetClientVersionMessage(entity this)
        }
 }
 
-string getwelcomemessage(entity this)
+void SendWelcomemessage(entity this, bool force_centerprint)
 {
+       msg_entity = this;
+       WriteHeader(MSG_ONE, TE_CSQC_SERVERINFO);
+       WriteByte(MSG_ONE, force_centerprint);
+       WriteString(MSG_ONE, autocvar_hostname);
+       WriteString(MSG_ONE, GetClientVersionMessage(this));
+       WriteString(MSG_ONE, gamemode_name);
+
        MUTATOR_CALLHOOK(BuildMutatorsPrettyString, "");
        string modifications = M_ARGV(0, string);
 
@@ -1055,12 +1062,7 @@ string getwelcomemessage(entity this)
                modifications = strcat(modifications, ", Jet pack");
        modifications = substring(modifications, 2, strlen(modifications) - 2);
 
-       string s = GetClientVersionMessage(this);
-
-       s = strcat(s, "^8\n\nmatch type is ^1", gamemode_name, "^8\n");
-
-       if(modifications != "")
-               s = strcat(s, "^8\nactive modifications: ^3", modifications, "^8\n");
+       WriteString(MSG_ONE, modifications);
 
        if(cache_lastmutatormsg != autocvar_g_mutatormsg)
        {
@@ -1068,29 +1070,14 @@ string getwelcomemessage(entity this)
                strcpy(cache_mutatormsg, cache_lastmutatormsg);
        }
 
-       if (cache_mutatormsg != "") {
-               s = strcat(s, "\n\n^8special gameplay tips: ^7", cache_mutatormsg);
-       }
+       WriteString(MSG_ONE, cache_mutatormsg);
 
        string mutator_msg = "";
        MUTATOR_CALLHOOK(BuildGameplayTipsString, mutator_msg);
        mutator_msg = M_ARGV(0, string);
 
-       s = strcat(s, mutator_msg); // trust that the mutator will do proper formatting
-
-       string motd = autocvar_sv_motd;
-       if (motd != "") {
-               s = strcat(s, "\n\n^8MOTD: ^7", strreplace("\\n", "\n", motd));
-       }
-       return s;
-}
-
-void serverinfo_welcomemessage_send(entity this)
-{
-       msg_entity = this;
-       WriteHeader(MSG_ONE, TE_CSQC_SERVERINFO);
-       WriteString(MSG_ONE, autocvar_hostname);
-       WriteString(MSG_ONE, getwelcomemessage(this));
+       WriteString(MSG_ONE, mutator_msg); // trust that the mutator will do proper formatting
+       WriteString(MSG_ONE, strreplace("\\n", "\n", autocvar_sv_motd));
 }
 
 /**
@@ -1182,7 +1169,7 @@ void ClientConnect(entity this)
        if (IS_REAL_CLIENT(this))
        {
                if (!autocvar_g_campaign)
-                       serverinfo_welcomemessage_send(this);
+                       SendWelcomemessage(this, false);
                sv_notice_join(this);
        }
 
@@ -2063,7 +2050,7 @@ void PrintWelcomeMessage(entity this)
                } else {
                        if (PHYS_INPUT_BUTTON_INFO(this)) {
                                CS(this).motd_actived_time = time;
-                               Send_Notification(NOTIF_ONE_ONLY, this, MSG_CENTER, CENTER_MOTD, getwelcomemessage(this));
+                               SendWelcomemessage(this, true);
                        }
                }
        }
index 344cba0eb0afcf657f25ffe52cac3ad15c50ed56..802afc8bde6f86e1ed3e145df61f111ea51ec715 100644 (file)
@@ -8,7 +8,5 @@ int autocvar_sv_clientcommand_antispam_count;
 
 string MapVote_Suggest(entity this, string m);
 
-void serverinfo_welcomemessage_send(entity this);
-
 // used by common/command/generic.qc:GenericCommand_dumpcommands to list all commands into a .txt file
 void ClientCommand_macro_write_aliases(float fh);