Fix networking being completely bamboozled

This commit is contained in:
Evil Factory
2026-02-10 20:26:46 -03:00
parent 9dde5cac7d
commit 6bbe5be5e6
4 changed files with 5 additions and 7 deletions

View File

@@ -604,8 +604,6 @@ namespace Barotrauma.Networking
{
ServerPacketHeader header = (ServerPacketHeader)inc.ReadByte();
GameMain.LuaCs.EventService.PublishEvent<IEventServerRawNetMessageReceived>(p => p.OnReceivedServerNetMessage(inc, header));
if (roundInitStatus == RoundInitStatus.WaitingForStartGameFinalize
&& header is not (
ServerPacketHeader.STARTGAMEFINALIZE

View File

@@ -838,8 +838,6 @@ namespace Barotrauma.Networking
ClientPacketHeader header = (ClientPacketHeader)inc.ReadByte();
GameMain.LuaCs.EventService.PublishEvent<IEventClientRawNetMessageReceived>(p => p.OnReceivedClientNetMessage(inc, header, sender));
switch (header)
{
case ClientPacketHeader.PING_RESPONSE:

View File

@@ -69,8 +69,9 @@ internal class HarmonyEventPatchesService : IService
[HarmonyPatch(typeof(GameClient), "ReadDataMessage"), HarmonyPrefix]
public static void GameClient_ReadDataMessage_Pre(IReadMessage inc)
{
ServerPacketHeader header = (ServerPacketHeader)inc.PeekByte(); // Read but don't advance the read pointer
ServerPacketHeader header = (ServerPacketHeader)inc.ReadByte();
_eventService.PublishEvent<IEventServerRawNetMessageReceived>(x => x.OnReceivedServerNetMessage(inc, header));
inc.BitPosition -= 8; // rewind so the game can read the message
}
[HarmonyPatch(typeof(SubEditorScreen), nameof(SubEditorScreen.Select), new Type[] { }), HarmonyPostfix]
@@ -88,8 +89,9 @@ internal class HarmonyEventPatchesService : IService
[HarmonyPatch(typeof(GameServer), "ReadDataMessage"), HarmonyPrefix]
public static void GameServer_ReadDataMessage_Pre(NetworkConnection sender, IReadMessage inc)
{
ClientPacketHeader header = (ClientPacketHeader)inc.PeekByte(); // Read but don't advance the read pointer
ClientPacketHeader header = (ClientPacketHeader)inc.ReadByte();
_eventService.PublishEvent<IEventClientRawNetMessageReceived>(x => x.OnReceivedClientNetMessage(inc, header, sender));
inc.BitPosition -= 8; // rewind so the game can read the message
}
#endif

View File

@@ -224,7 +224,7 @@ internal partial class NetworkingService : INetworkingService
#if CLIENT
SendToServer(message);
#elif SERVER
SendToClient(message);
SendToClient(message, connection);
#endif
}