From: terencehill Date: Thu, 24 Mar 2022 22:47:43 +0000 (+0100) Subject: Allow translating version message X-Git-Tag: xonotic-v0.8.5~81^2~10 X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=c8b15254b6be6b8b2b842afd767127e02ff4c364;p=xonotic%2Fxonotic-data.pk3dir.git Allow translating version message --- diff --git a/qcsrc/client/main.qc b/qcsrc/client/main.qc index cefd2c471..086420899 100644 --- a/qcsrc/client/main.qc +++ b/qcsrc/client/main.qc @@ -1314,11 +1314,34 @@ string translate_weaponarena(string s) return sprintf(_("%s Arena"), wpn_list); } +string GetVersionMessage(string hostversion, bool version_mismatch, bool version_check) +{ + string xonotic_hostversion = strcat("Xonotic ", hostversion); + if (version_mismatch) + { + if(!version_check) + return strcat(sprintf(_("This is %s"), xonotic_hostversion), "\n^3", + _("Your client version is outdated."), "\n\n\n", + _("### YOU WON'T BE ABLE TO PLAY ON THIS SERVER ###"), "\n\n\n", + _("Please update!")); + else + return strcat(sprintf(_("This is %s"), xonotic_hostversion), "\n^3", + _("This server is using an outdated Xonotic version."), "\n\n\n", + _("### THIS SERVER IS INCOMPATIBLE AND THUS YOU CANNOT JOIN ###")); + } + return sprintf(_("Welcome to %s"), xonotic_hostversion); +} + NET_HANDLE(TE_CSQC_SERVERINFO, bool isNew) { bool force_centerprint = ReadByte(); string hostname = ReadString(); - string ver = ReadString(); + + string hostversion = ReadString(); + bool version_mismatch = ReadByte(); + bool version_check = ReadByte(); + string ver = GetVersionMessage(hostversion, version_mismatch, version_check); + string modifications = translate_modifications(ReadString()); string weaponarena_list = translate_weaponarena(ReadString()); string cache_mutatormsg = ReadString(); diff --git a/qcsrc/server/client.qc b/qcsrc/server/client.qc index c46c151f2..15cac948a 100644 --- a/qcsrc/server/client.qc +++ b/qcsrc/server/client.qc @@ -1018,28 +1018,15 @@ void ClientPreConnect(entity this) } #endif -string GetClientVersionMessage(entity this) -{ - if (CS(this).version_mismatch) { - if(CS(this).version < autocvar_gameversion) { - return strcat("This is Xonotic ", autocvar_g_xonoticversion, - "\n^3Your client version is outdated.\n\n\n### YOU WON'T BE ABLE TO PLAY ON THIS SERVER ###\n\n\nPlease update!!!^8"); - } else { - return strcat("This is Xonotic ", autocvar_g_xonoticversion, - "\n^3This server is using an outdated Xonotic version.\n\n\n ### THIS SERVER IS INCOMPATIBLE AND THUS YOU CANNOT JOIN ###.^8"); - } - } else { - return strcat("Welcome to Xonotic ", autocvar_g_xonoticversion); - } -} - 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, autocvar_g_xonoticversion); + WriteByte(MSG_ONE, CS(this).version_mismatch); + WriteByte(MSG_ONE, (CS(this).version < autocvar_gameversion)); MUTATOR_CALLHOOK(BuildMutatorsPrettyString, ""); string modifications = M_ARGV(0, string);