From 605be3947fd5feb3c0ff277dfce72d78e16388b0 Mon Sep 17 00:00:00 2001 From: Sanae Date: Wed, 27 Apr 2022 14:17:02 -0600 Subject: [PATCH] I'm going to commit war crimes --- Server/Client.cs | 7 +++---- Server/Server.cs | 2 +- Shared/Packet/Packets/GamePacket.cs | 4 ++-- 3 files changed, 6 insertions(+), 7 deletions(-) diff --git a/Server/Client.cs b/Server/Client.cs index 409105c..1507909 100644 --- a/Server/Client.cs +++ b/Server/Client.cs @@ -41,15 +41,14 @@ public class Client : IDisposable { if (packetAttribute.Type is not PacketType.Cap and not PacketType.Player) Logger.Info($"Pre-header {packetAttribute.Type} ({(short)packetAttribute.Type}) - {typeof(T)}"); try { - PacketHeader header = new PacketHeader { + Server.FillPacket(new PacketHeader { Id = sender?.Id ?? Id, Type = packetAttribute.Type, PacketSize = packet.Size - }; - Server.FillPacket(header, packet, memory.Memory); + }, packet, memory.Memory); } catch (Exception e) { - Logger.Error($"I will lose my shit {e}"); + Logger.Error($"I will lose my shit {e} {memory.Memory.Span[..Constants.HeaderSize].Length} {memory.Memory.Span[Constants.HeaderSize..].Length} {packet.Size}"); } if (packetAttribute.Type is not PacketType.Cap and not PacketType.Player) diff --git a/Server/Server.cs b/Server/Server.cs index 85e6a97..cbdd2de 100644 --- a/Server/Server.cs +++ b/Server/Server.cs @@ -59,7 +59,7 @@ public class Server { public static void FillPacket(PacketHeader header, T packet, Memory memory) where T : struct, IPacket { Span data = memory.Span; - + header.Serialize(data[..Constants.HeaderSize]); packet.Serialize(data[Constants.HeaderSize..]); } diff --git a/Shared/Packet/Packets/GamePacket.cs b/Shared/Packet/Packets/GamePacket.cs index dc39066..35ec444 100644 --- a/Shared/Packet/Packets/GamePacket.cs +++ b/Shared/Packet/Packets/GamePacket.cs @@ -12,9 +12,9 @@ public struct GamePacket : IPacket { public GamePacket() { } - public short Size => 0x3A; + public short Size => 0x3C; public void Serialize(Span data) { - MemoryMarshal.Write(data[..0], ref Is2d); + MemoryMarshal.Write(data, ref Is2d); MemoryMarshal.Write(data[1..], ref ScenarioNum); Encoding.UTF8.GetBytes(Stage).CopyTo(data[2..(2 + StageSize)]); }