From: bones_was_here Date: Fri, 29 Mar 2024 08:46:29 +0000 (+1000) Subject: Welcome message: combine bool networking into a bitfield X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=a03a8c800511aaa57ac75d2a690a81b886bdbf80;p=xonotic%2Fxonotic-data.pk3dir.git Welcome message: combine bool networking into a bitfield --- diff --git a/qcsrc/client/main.qc b/qcsrc/client/main.qc index 90917341a..9d45c4554 100644 --- a/qcsrc/client/main.qc +++ b/qcsrc/client/main.qc @@ -1414,7 +1414,9 @@ string GetVersionMessage(string hostversion, bool version_mismatch, bool version bool net_handle_ServerWelcome() { - campaign = ReadByte(); + int flags = ReadByte(); + + campaign = flags & 1; if (campaign) { int campaign_level = ReadByte(); @@ -1435,8 +1437,8 @@ bool net_handle_ServerWelcome() strcpy(hostname, ReadString()); string hostversion = ReadString(); - bool version_mismatch = ReadByte(); - bool version_check = ReadByte(); + bool version_mismatch = flags & 2; + bool version_check = flags & 4; srv_minplayers = ReadByte(); srv_maxplayers = ReadByte(); string modifications = translate_modifications(ReadString()); diff --git a/qcsrc/server/client.qc b/qcsrc/server/client.qc index c1ee3aceb..408573623 100644 --- a/qcsrc/server/client.qc +++ b/qcsrc/server/client.qc @@ -1041,16 +1041,23 @@ void ClientPreConnect(entity this) // also note that they aren't all registered mutators, e.g. jetpack, low gravity void SendWelcomeMessage(entity this, int msg_type) { - WriteByte(msg_type, boolean(autocvar_g_campaign)); if (boolean(autocvar_g_campaign)) { + WriteByte(msg_type, 1); WriteByte(msg_type, Campaign_GetLevelNum()); return; } + + int flags = 0; + if (CS(this).version_mismatch) + flags |= 2; + if (CS(this).version < autocvar_gameversion) + flags |= 4; + WriteByte(msg_type, flags); + WriteString(msg_type, autocvar_hostname); WriteString(msg_type, autocvar_g_xonoticversion); - WriteByte(msg_type, CS(this).version_mismatch); - WriteByte(msg_type, (CS(this).version < autocvar_gameversion)); + WriteByte(msg_type, autocvar_g_warmup > 1 ? autocvar_g_warmup : map_minplayers); WriteByte(msg_type, GetPlayerLimit());