From 845fcefad7b899532cb33a8e4b8e75c49ee9ff12 Mon Sep 17 00:00:00 2001 From: Evil Factory <36804725+evilfactory@users.noreply.github.com> Date: Sun, 1 Mar 2026 09:50:52 -0300 Subject: [PATCH] Fix Start(0 not returning an empty write only message --- .../LuaCs/Compatibility/ILuaCsNetworking.cs | 1 + .../LuaCs/_Services/NetworkingService.cs | 12 +++++++++++- 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/Barotrauma/BarotraumaShared/SharedSource/LuaCs/Compatibility/ILuaCsNetworking.cs b/Barotrauma/BarotraumaShared/SharedSource/LuaCs/Compatibility/ILuaCsNetworking.cs index 0f2388df9..4aae5b61e 100644 --- a/Barotrauma/BarotraumaShared/SharedSource/LuaCs/Compatibility/ILuaCsNetworking.cs +++ b/Barotrauma/BarotraumaShared/SharedSource/LuaCs/Compatibility/ILuaCsNetworking.cs @@ -15,6 +15,7 @@ internal interface ILuaCsNetworking : ILuaCsShim int FileSenderMaxPacketsPerUpdate { get; set; } void ClientWriteLobby(Client client); void UpdateClientPermissions(Client client); + IWriteMessage Start(); void Send(IWriteMessage mesage, NetworkConnection connection = null, DeliveryMethod deliveryMethod = DeliveryMethod.Reliable); #elif CLIENT void Send(IWriteMessage mesage, DeliveryMethod deliveryMethod = DeliveryMethod.Reliable); diff --git a/Barotrauma/BarotraumaShared/SharedSource/LuaCs/_Services/NetworkingService.cs b/Barotrauma/BarotraumaShared/SharedSource/LuaCs/_Services/NetworkingService.cs index 622f7395f..8482bebc3 100644 --- a/Barotrauma/BarotraumaShared/SharedSource/LuaCs/_Services/NetworkingService.cs +++ b/Barotrauma/BarotraumaShared/SharedSource/LuaCs/_Services/NetworkingService.cs @@ -127,8 +127,18 @@ internal partial class NetworkingService : INetworkingService public void Receive(string netIdString, NetMessageReceived callback) => Receive(new NetId(netIdString), callback); public void Receive(Guid netIdGuid, NetMessageReceived callback) => Receive(new NetId(netIdGuid.ToString()), callback); - public IWriteMessage Start(string netIdString) => Start(new NetId(netIdString)); + public IWriteMessage Start(string netIdString) + { + if (netIdString == null) + { + // idk why but Lua calls this method with null instead of the Start method with no arguments + return new WriteOnlyMessage(); + } + + return Start(new NetId(netIdString)); + } public IWriteMessage Start(Guid netIdGuid) => Start(new NetId(netIdGuid.ToString())); + public IWriteMessage Start() => new WriteOnlyMessage(); internal void Receive(NetId netId, NetMessageReceived callback) {