Fix garbage network data being read by the game when reading LuaCs network messages
This commit is contained in:
@@ -124,9 +124,10 @@ internal class HarmonyEventPatchesService : ISystem
|
||||
[HarmonyPatch(typeof(GameClient), "ReadDataMessage"), HarmonyPrefix]
|
||||
public static void GameClient_ReadDataMessage_Pre(IReadMessage inc)
|
||||
{
|
||||
int prevBitPosition = inc.BitPosition;
|
||||
ServerPacketHeader header = (ServerPacketHeader)inc.ReadByte();
|
||||
_eventService.PublishEvent<IEventServerRawNetMessageReceived>(x => x.OnReceivedServerNetMessage(inc, header));
|
||||
inc.BitPosition -= 8; // rewind so the game can read the message
|
||||
inc.BitPosition = prevBitPosition; // rewind so the game can read the message
|
||||
}
|
||||
|
||||
[HarmonyPatch(typeof(SubEditorScreen), nameof(SubEditorScreen.Select), new Type[] { }), HarmonyPostfix]
|
||||
@@ -160,9 +161,10 @@ internal class HarmonyEventPatchesService : ISystem
|
||||
[HarmonyPatch(typeof(GameServer), "ReadDataMessage"), HarmonyPrefix]
|
||||
public static void GameServer_ReadDataMessage_Pre(NetworkConnection sender, IReadMessage inc)
|
||||
{
|
||||
int prevBitPosition = inc.BitPosition;
|
||||
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
|
||||
inc.BitPosition = prevBitPosition; // rewind so the game can read the message
|
||||
}
|
||||
|
||||
[HarmonyPatch(typeof(GameServer), "OnInitializationComplete"), HarmonyPostfix]
|
||||
|
||||
Reference in New Issue
Block a user