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:
parent
eaa03467e6
commit
cdad20ddd2
1 changed files with 16 additions and 16 deletions
|
@ -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,28 +27,27 @@ 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 {
|
MemoryMarshal.Write(owner.Memory.Span, ref coolHeader);
|
||||||
coolHeader.Id = new Guid(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, (byte)i);
|
// unbelievably shitty way to marshal playerpacket
|
||||||
MemoryMarshal.Write(owner.Memory.Span, ref coolHeader);
|
fixed (byte* basePtr = owner.Memory.Span) {
|
||||||
// unbelievably shitty way to marshal playerpacket
|
byte* dataPtr = basePtr + Constants.HeaderSize;
|
||||||
fixed (byte* basePtr = owner.Memory.Span) {
|
Vector3 pos = Unsafe.Read<Vector3>(dataPtr);
|
||||||
byte* dataPtr = basePtr + Constants.HeaderSize;
|
pos.X += 1000f * (float)Math.Cos(d);
|
||||||
Vector3 pos = Unsafe.Read<Vector3>(dataPtr);
|
pos.Z += 1000f * (float)Math.Sin(d);
|
||||||
pos.X += 1000f * (float)Math.Cos(d);
|
Unsafe.Write(dataPtr, pos);
|
||||||
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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue