Fix networking being completely bamboozled
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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:
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
@@ -224,7 +224,7 @@ internal partial class NetworkingService : INetworkingService
|
||||
#if CLIENT
|
||||
SendToServer(message);
|
||||
#elif SERVER
|
||||
SendToClient(message);
|
||||
SendToClient(message, connection);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user