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);
|
||||
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<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++) {
|
||||
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<Vector3>(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<Vector3>(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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue