0
0
Fork 0
mirror of https://github.com/Sanae6/SmoOnlineServer.git synced 2024-11-22 03:05:16 +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); TcpClient client = new TcpClient("127.0.0.1", 1027);
Guid ownId = new Guid(); Guid ownId = new Guid();
Guid otherId = Guid.Empty;
Logger logger = new Logger("Client"); Logger logger = new Logger("Client");
NetworkStream stream = client.GetStream(); NetworkStream stream = client.GetStream();
PacketHeader coolHeader = new PacketHeader { PacketHeader coolHeader = new PacketHeader {
Type = PacketType.Connect, Type = PacketType.Connect,
Sender = PacketSender.Client, Sender = PacketSender.Client,
Id = Guid.Empty Id = ownId
}; };
int e = 0; int e = 0;
@ -26,15 +27,15 @@ async Task S() {
await stream.ReadAsync(owner.Memory); await stream.ReadAsync(owner.Memory);
PacketHeader header = MemoryMarshal.Read<PacketHeader>(owner.Memory.Span); PacketHeader header = MemoryMarshal.Read<PacketHeader>(owner.Memory.Span);
if (header.Type == PacketType.Player) { if (header.Type == PacketType.Player) {
if (otherId == Guid.Empty) otherId = header.Id;
if (otherId != header.Id) continue;
if (e++ != 0) { if (e++ != 0) {
e %= 3; e %= 3;
continue; continue;
} }
d += Math.PI; d += Math.PI / 180;
for (int i = 0; i < 1; i++) {
unsafe { unsafe {
coolHeader.Id = new Guid(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, (byte)i);
MemoryMarshal.Write(owner.Memory.Span, ref coolHeader); MemoryMarshal.Write(owner.Memory.Span, ref coolHeader);
// unbelievably shitty way to marshal playerpacket // unbelievably shitty way to marshal playerpacket
fixed (byte* basePtr = owner.Memory.Span) { fixed (byte* basePtr = owner.Memory.Span) {
@ -45,12 +46,11 @@ async Task S() {
Unsafe.Write(dataPtr, pos); 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); await stream.WriteAsync(owner.Memory);
} }
} }
} }
}
IMemoryOwner<byte> owner = MemoryPool<byte>.Shared.Rent(256); IMemoryOwner<byte> owner = MemoryPool<byte>.Shared.Rent(256);
MemoryMarshal.Write(owner.Memory.Span[..], ref coolHeader); MemoryMarshal.Write(owner.Memory.Span[..], ref coolHeader);
ConnectPacket connect = new ConnectPacket { ConnectPacket connect = new ConnectPacket {