2021-11-29 18:09:12 +00:00
|
|
|
|
using System.Buffers;
|
|
|
|
|
using System.Net.Sockets;
|
|
|
|
|
using System.Numerics;
|
2021-11-29 04:04:34 +00:00
|
|
|
|
using System.Runtime.InteropServices;
|
|
|
|
|
using Shared;
|
|
|
|
|
using Shared.Packet;
|
|
|
|
|
using Shared.Packet.Packets;
|
|
|
|
|
|
2022-02-10 01:42:46 +00:00
|
|
|
|
TcpClient client = new TcpClient(args[0], 1027);
|
2022-02-04 09:45:38 +00:00
|
|
|
|
Guid ownId = new Guid(1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
|
2022-02-03 03:41:47 +00:00
|
|
|
|
Guid otherId = Guid.Empty;
|
2021-11-29 04:04:34 +00:00
|
|
|
|
Logger logger = new Logger("Client");
|
|
|
|
|
NetworkStream stream = client.GetStream();
|
|
|
|
|
|
2021-11-29 18:09:12 +00:00
|
|
|
|
int e = 0;
|
|
|
|
|
double d = 0;
|
2022-02-04 09:45:38 +00:00
|
|
|
|
Vector3 basePoint = Vector3.Zero;
|
|
|
|
|
PlayerPacket? playerPacket = null;
|
|
|
|
|
|
2022-02-08 22:46:12 +00:00
|
|
|
|
PacketType[] reboundPackets = {
|
|
|
|
|
PacketType.Player,
|
|
|
|
|
PacketType.Cap,
|
|
|
|
|
PacketType.Capture,
|
|
|
|
|
PacketType.Costume,
|
|
|
|
|
PacketType.Tag,
|
|
|
|
|
PacketType.Shine
|
|
|
|
|
};
|
2021-11-29 04:04:34 +00:00
|
|
|
|
|
2021-11-29 18:09:12 +00:00
|
|
|
|
async Task S() {
|
|
|
|
|
IMemoryOwner<byte> owner = MemoryPool<byte>.Shared.Rent(256);
|
|
|
|
|
while (true) {
|
|
|
|
|
await stream.ReadAsync(owner.Memory);
|
2022-02-08 22:46:12 +00:00
|
|
|
|
PacketHeader header = MemoryMarshal.Read<PacketHeader>(owner.Memory.Span);
|
|
|
|
|
PacketType type = header.Type;
|
|
|
|
|
if (reboundPackets.All(x => x != type)) continue;
|
|
|
|
|
header.Id = ownId;
|
|
|
|
|
MemoryMarshal.Write(owner.Memory.Span, ref header);
|
|
|
|
|
await stream.WriteAsync(owner.Memory);
|
2021-11-29 18:09:12 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
2022-02-04 09:45:38 +00:00
|
|
|
|
|
|
|
|
|
PacketHeader coolHeader = new PacketHeader {
|
|
|
|
|
Type = PacketType.Connect,
|
|
|
|
|
Id = ownId
|
|
|
|
|
};
|
2021-11-29 18:09:12 +00:00
|
|
|
|
IMemoryOwner<byte> owner = MemoryPool<byte>.Shared.Rent(256);
|
|
|
|
|
MemoryMarshal.Write(owner.Memory.Span[..], ref coolHeader);
|
|
|
|
|
ConnectPacket connect = new ConnectPacket {
|
|
|
|
|
ConnectionType = ConnectionTypes.FirstConnection
|
|
|
|
|
};
|
|
|
|
|
MemoryMarshal.Write(owner.Memory.Span[Constants.HeaderSize..256], ref connect);
|
|
|
|
|
await stream.WriteAsync(owner.Memory);
|
|
|
|
|
coolHeader.Type = PacketType.Player;
|
|
|
|
|
MemoryMarshal.Write(owner.Memory.Span[..], ref coolHeader);
|
2022-02-04 09:45:38 +00:00
|
|
|
|
logger.Info("Connected");
|
2021-11-29 18:09:12 +00:00
|
|
|
|
await S();
|