0
0
Fork 0
mirror of https://github.com/Sanae6/SmoOnlineServer.git synced 2024-11-24 20:25:18 +00:00

better client base, need to setup id targeting system

This commit is contained in:
Sanae 2022-02-02 21:41:47 -06:00
parent eaa03467e6
commit cdad20ddd2

View file

@ -9,12 +9,13 @@ using Shared.Packet.Packets;
TcpClient client = new TcpClient("127.0.0.1", 1027);
Guid ownId = new Guid();
Guid otherId = Guid.Empty;
Logger logger = new Logger("Client");
NetworkStream stream = client.GetStream();
PacketHeader coolHeader = new PacketHeader {
Type = PacketType.Connect,
Sender = PacketSender.Client,
Id = Guid.Empty
Id = ownId
};
int e = 0;
@ -26,15 +27,15 @@ async Task S() {
await stream.ReadAsync(owner.Memory);
PacketHeader header = MemoryMarshal.Read<PacketHeader>(owner.Memory.Span);
if (header.Type == PacketType.Player) {
if (otherId == Guid.Empty) otherId = header.Id;
if (otherId != header.Id) continue;
if (e++ != 0) {
e %= 3;
continue;
}
d += Math.PI;
for (int i = 0; i < 1; i++) {
d += Math.PI / 180;
unsafe {
coolHeader.Id = new Guid(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, (byte)i);
MemoryMarshal.Write(owner.Memory.Span, ref coolHeader);
// unbelievably shitty way to marshal playerpacket
fixed (byte* basePtr = owner.Memory.Span) {
@ -45,11 +46,10 @@ async Task S() {
Unsafe.Write(dataPtr, pos);
}
}
// Console.WriteLine($"aargh {coolHeader.Id} {owner.Memory.Span.Hex()}");
Console.WriteLine($"aargh {coolHeader.Id} {owner.Memory.Span[..256].Hex()}");
await stream.WriteAsync(owner.Memory);
}
}
}
}
IMemoryOwner<byte> owner = MemoryPool<byte>.Shared.Rent(256);
MemoryMarshal.Write(owner.Memory.Span[..], ref coolHeader);