From 29bb51aab279483c2113101902a6a96a6a0ab63a Mon Sep 17 00:00:00 2001 From: terencehill Date: Wed, 23 Mar 2022 03:23:14 +0100 Subject: [PATCH] Welcome message: fix broken version check by giving the client time to send its version. This change also allows getting the gametype name from the gametype entity instead of receiving it from the server (and gametype name is now translatable) --- qcsrc/client/main.qc | 3 +-- qcsrc/server/client.qc | 14 ++++++++++++-- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/qcsrc/client/main.qc b/qcsrc/client/main.qc index 5e04e7160..d1f6e1b8d 100644 --- a/qcsrc/client/main.qc +++ b/qcsrc/client/main.qc @@ -1291,7 +1291,6 @@ NET_HANDLE(TE_CSQC_SERVERINFO, bool isNew) bool force_centerprint = ReadByte(); string hostname = ReadString(); string ver = ReadString(); - string gamemode_name = ReadString(); string modifications = ReadString(); string cache_mutatormsg = ReadString(); string mutator_msg = ReadString(); @@ -1299,7 +1298,7 @@ NET_HANDLE(TE_CSQC_SERVERINFO, bool isNew) string msg = ""; msg = strcat(msg, ver); - msg = strcat(msg, "^8\n\n", _("match type is "), " ^1", gamemode_name, "^8\n"); + msg = strcat(msg, "^8\n\n", _("match type is "), " ^1", MapInfo_Type_ToText(gametype), "^8\n"); if(modifications != "") msg = strcat(msg, "^8\n", _("active modifications:"), " ^3", modifications, "^8\n"); if (cache_mutatormsg != "") diff --git a/qcsrc/server/client.qc b/qcsrc/server/client.qc index cadb523cf..a1c4c7003 100644 --- a/qcsrc/server/client.qc +++ b/qcsrc/server/client.qc @@ -1040,7 +1040,6 @@ void SendWelcomemessage(entity this, bool force_centerprint) 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); @@ -1080,6 +1079,17 @@ void SendWelcomemessage(entity this, bool force_centerprint) WriteString(MSG_ONE, strreplace("\\n", "\n", autocvar_sv_motd)); } +void SendWelcomemessage_onConnection_think(entity this) +{ + SendWelcomemessage(this, false); +} + +void SendWelcomemessage_onConnection(entity this) +{ + // give the client time to sent its version + defer(this, 0.5, SendWelcomemessage_onConnection_think); +} + /** ============= ClientConnect @@ -1169,7 +1179,7 @@ void ClientConnect(entity this) if (IS_REAL_CLIENT(this)) { if (!autocvar_g_campaign) - SendWelcomemessage(this, false); + SendWelcomemessage_onConnection(this); sv_notice_join(this); } -- 2.39.2