From cdad20ddd2f7b60903eebc3523d5ebde3876ae45 Mon Sep 17 00:00:00 2001 From: Sanae Date: Wed, 2 Feb 2022 21:41:47 -0600 Subject: [PATCH] better client base, need to setup id targeting system --- TestClient/Program.cs | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/TestClient/Program.cs b/TestClient/Program.cs index a748574..1dce625 100644 --- a/TestClient/Program.cs +++ b/TestClient/Program.cs @@ -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,28 +27,27 @@ async Task S() { await stream.ReadAsync(owner.Memory); PacketHeader header = MemoryMarshal.Read(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++) { - 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) { - byte* dataPtr = basePtr + Constants.HeaderSize; - Vector3 pos = Unsafe.Read(dataPtr); - pos.X += 1000f * (float)Math.Cos(d); - pos.Z += 1000f * (float)Math.Sin(d); - Unsafe.Write(dataPtr, pos); - } + d += Math.PI / 180; + unsafe { + MemoryMarshal.Write(owner.Memory.Span, ref coolHeader); + // unbelievably shitty way to marshal playerpacket + fixed (byte* basePtr = owner.Memory.Span) { + byte* dataPtr = basePtr + Constants.HeaderSize; + Vector3 pos = Unsafe.Read(dataPtr); + pos.X += 1000f * (float)Math.Cos(d); + pos.Z += 1000f * (float)Math.Sin(d); + Unsafe.Write(dataPtr, pos); } - // Console.WriteLine($"aargh {coolHeader.Id} {owner.Memory.Span.Hex()}"); - await stream.WriteAsync(owner.Memory); } + Console.WriteLine($"aargh {coolHeader.Id} {owner.Memory.Span[..256].Hex()}"); + await stream.WriteAsync(owner.Memory); } } }