mirror of
https://github.com/Sanae6/SmoOnlineServer.git
synced 2024-11-21 18:55:17 +00:00
I'm going to commit war crimes
This commit is contained in:
parent
df2e976782
commit
605be3947f
3 changed files with 6 additions and 7 deletions
|
@ -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)
|
||||
|
|
|
@ -59,7 +59,7 @@ public class Server {
|
|||
|
||||
public static void FillPacket<T>(PacketHeader header, T packet, Memory<byte> memory) where T : struct, IPacket {
|
||||
Span<byte> data = memory.Span;
|
||||
|
||||
|
||||
header.Serialize(data[..Constants.HeaderSize]);
|
||||
packet.Serialize(data[Constants.HeaderSize..]);
|
||||
}
|
||||
|
|
|
@ -12,9 +12,9 @@ public struct GamePacket : IPacket {
|
|||
|
||||
public GamePacket() { }
|
||||
|
||||
public short Size => 0x3A;
|
||||
public short Size => 0x3C;
|
||||
public void Serialize(Span<byte> 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)]);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue