Remove test exception when disconnecting

This commit is contained in:
Sanae 2022-03-13 15:27:53 -06:00
parent c778d15644
commit 217dc2765e
2 changed files with 8 additions and 2 deletions

View File

@ -136,7 +136,7 @@ public class Server {
}
if (!await Read(memory.Memory[..Constants.HeaderSize], Constants.HeaderSize, 0))
throw new Exception("Not enough bytes for packet header sent to server");
break;
PacketHeader header = GetHeader(memory.Memory.Span[..Constants.HeaderSize]);
Range packetRange = Constants.HeaderSize..(Constants.HeaderSize + header.PacketSize);
if (header.PacketSize > 0) {
@ -145,7 +145,7 @@ public class Server {
memTemp.Memory.Span[..Constants.HeaderSize].CopyTo(memory.Memory.Span[..Constants.HeaderSize]);
memTemp.Dispose();
if (!await Read(memory.Memory, header.PacketSize, Constants.HeaderSize))
throw new Exception("Not enough bytes for packet data sent to server");
break;
}
// if (header.Type is not PacketType.Player and not PacketType.Cap and not PacketType.Capture)Logger.Info($"Got your mom {header.Id} {header.Type} 0x{header.PacketSize:X} 0x{memory.Memory.Length:X} 0x{header.Size:X}");

View File

@ -10,6 +10,12 @@ public struct GamePacket : IPacket {
public byte ScenarioNum;
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = StageSize)]
public string Stage = "";
public GamePacket() {
Is2d = false;
ScenarioNum = 0;
}
public short Size => 0x32;
public void Serialize(Span<byte> data) {
MemoryMarshal.Write(data[..0], ref Is2d);