From 3bcee35c7b908857deab0eefec0eb38d30500f4e Mon Sep 17 00:00:00 2001 From: Kp Date: Sat, 26 Aug 2017 19:47:51 +0000 Subject: [PATCH] Shrink some Netgame fields For protocol compatibility, zero-pad the outbound messages. Previously, the upper bits were zero because the value fit in a byte. --- common/main/multi.h | 15 +++++---------- similar/main/net_udp.cpp | 15 ++++++++++----- 2 files changed, 15 insertions(+), 15 deletions(-) diff --git a/common/main/multi.h b/common/main/multi.h index 7684ff8af..6ea05f7ea 100644 --- a/common/main/multi.h +++ b/common/main/multi.h @@ -777,17 +777,12 @@ struct netgame_info : prohibit_void_ptr, ignore_window_pointer_t packed_spawn_granted_items SpawnGrantedItems; packed_netduplicate_items DuplicatePowerups; #if defined(DXX_BUILD_DESCENT_II) - /* - * Only used in Descent II, but defined in both for historical - * reasons - */ - short Allow_marker_view; - short AlwaysLighting; - /* End Descent II */ + uint8_t Allow_marker_view; + uint8_t AlwaysLighting; #endif - short ShowEnemyNames; - short BrightPlayers; - short InvulAppear; + uint8_t ShowEnemyNames; + uint8_t BrightPlayers; + uint8_t InvulAppear; ushort segments_checksum; int KillGoal; fix PlayTimeAllowed; diff --git a/similar/main/net_udp.cpp b/similar/main/net_udp.cpp index bb85f7488..d09b98207 100644 --- a/similar/main/net_udp.cpp +++ b/similar/main/net_udp.cpp @@ -2543,12 +2543,17 @@ static uint_fast32_t net_udp_prepare_heavy_game_info(const _sockaddr *addr, ubyt #elif defined(DXX_BUILD_DESCENT_II) PUT_INTEL_SHORT(buf + len, Netgame.SpawnGrantedItems.mask); len += 2; PUT_INTEL_SHORT(buf + len, Netgame.DuplicatePowerups.get_packed_field()); len += 2; - PUT_INTEL_SHORT(buf + len, Netgame.Allow_marker_view); len += 2; - PUT_INTEL_SHORT(buf + len, Netgame.AlwaysLighting); len += 2; + buf[len++] = Netgame.Allow_marker_view; + buf[len++] = 0; + buf[len++] = Netgame.AlwaysLighting; + buf[len++] = 0; #endif - PUT_INTEL_SHORT(buf + len, Netgame.ShowEnemyNames); len += 2; - PUT_INTEL_SHORT(buf + len, Netgame.BrightPlayers); len += 2; - PUT_INTEL_SHORT(buf + len, Netgame.InvulAppear); len += 2; + buf[len++] = Netgame.ShowEnemyNames; + buf[len++] = 0; + buf[len++] = Netgame.BrightPlayers; + buf[len++] = 0; + buf[len++] = Netgame.InvulAppear; + buf[len++] = 0; range_for (const auto &i, Netgame.team_name) { memcpy(&buf[len], static_cast(i), (CALLSIGN_LEN+1));