From 36d7e25b8caf19219c588abff07e32fe06d0c6d0 Mon Sep 17 00:00:00 2001
From: James R <justsomejames2@gmail.com>
Date: Mon, 17 Feb 2025 14:29:59 -0800
Subject: [PATCH] rrserver.packets.SRB2.v55: ignore last byte of gametype and
 server_name

For this version, there is a bug in the server code that
neglects to write to the final byte of some string
buffers.
---
 rrserver/packets/SRB2/v55/__init__.py | 15 +++++++++++++--
 1 file changed, 13 insertions(+), 2 deletions(-)

diff --git a/rrserver/packets/SRB2/v55/__init__.py b/rrserver/packets/SRB2/v55/__init__.py
index ad6cdfe..9e3c66b 100644
--- a/rrserver/packets/SRB2/v55/__init__.py
+++ b/rrserver/packets/SRB2/v55/__init__.py
@@ -46,7 +46,12 @@ ServerInfo = Struct(
 	#
 	# Gameplay
 	#
-	'gametype' / PaddedString(24, 'ascii'),
+	# TODO: due to a bug in netcode/server_connection.c,
+	# SV_SendServerInfo, the last byte of some fields is
+	# not properly written. Until a solution is
+	# determined, we shall ignore this byte on the
+	# receiving end.
+	'gametype' / PaddedString(23, 'ascii'), Padding(1),
 	'modified' / Flag,
 	'cheats' / Flag,
 	'_flags' / FlagsEnum(
@@ -57,7 +62,13 @@ ServerInfo = Struct(
 	'_num_files' / u8,
 	'_askinfo_time' / u32,
 	'map_time' / TicrateAdapter(u32),
-	'server_name' / PrettyNameAdapter(PaddedCString(32)),
+	# TODO: due to a bug in netcode/server_connection.c,
+	# SV_SendServerInfo, the last byte of some fields is
+	# not properly written. Until a solution is
+	# determined, we shall ignore this byte on the
+	# receiving end.
+	'server_name' / PrettyNameAdapter(PaddedCString(31)),
+	Padding(1),
 
 	# netcode/server_connection.c, SV_SendServerInfo
 	# This is an 8-byte field, however only 7 bytes are
-- 
GitLab