/// <summary> /// Handles the auth request packet. /// </summary> /// <param name="client">The auth client.</param> /// <param name="Packet">The packet.</param> public static void Handle(Client.AuthClient client, DataPacket Packet) { using (var auth = new AuthRequestPacket(Packet)) { Enums.AccountStatus status = Database.ServerDatabase.Authenticate(client, auth.Account, auth.Password); client.EntityUID = (uint)ProjectX_V3_Lib.ThreadSafe.RandomGenerator.Generator.Next(1000000, 699999999); if (status == Enums.AccountStatus.Ready) { try { Database.ServerDatabase.UpdateAuthentication(client); Socket quicksock = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp); quicksock.Connect(new IPEndPoint(IPAddress.Parse(Program.Config.ReadString("GameIP")), Program.Config.ReadInt32("GameAuthPort"))); using (DataPacket packet = new DataPacket(44, 9001)) { packet.WriteString(Program.Config.ReadString("ServerPassword"), 4); packet.WriteString(client.Account, 20); packet.WriteInt32(client.DatabaseUID, 36); packet.WriteUInt32(client.EntityUID, 40); quicksock.BeginSend(packet.Copy(), 0, 44, SocketFlags.None, new AsyncCallback((ia) => { int send = quicksock.EndSend(ia); if (send != 44) { status = Enums.AccountStatus.Datebase_Error; client.EntityUID = 0; } Console.WriteLine("Database Notified: [Account: {0}] [DUID: {1}] [EUID: {2}]", client.Account, client.DatabaseUID, client.EntityUID); }), null); } System.Threading.Thread.Sleep(2000); } catch { status = Enums.AccountStatus.Datebase_Error; } } using (var resp = new AuthResponsePacket()) { if (status == Enums.AccountStatus.Ready) { Console.WriteLine("Incoming login. [Account: {0}] [Password: {1}]", client.Account, client.Password); resp.EntityUID = client.EntityUID; resp.Port = Program.Config.ReadUInt32("GamePort"); resp.IPAddress = Program.Config.ReadString("GameIP"); } else { resp.EntityUID = 0; } resp.AccountStatus = status; client.Send(resp); } System.Threading.Thread.Sleep(5000); client.NetworkClient.Disconnect("TIME_OUT"); } }
public void Append(DataPacket buffer, int offset, out int nextoffset) { nextoffset = offset; buffer.WriteString(Name, offset); buffer.WriteUInt32(Unknown16, offset + 16); buffer.WriteUInt32(Unknown20, offset + 20); buffer.WriteUInt32(Level, offset + 24); buffer.WriteUInt16((ushort)Rank, offset + 28); buffer.WriteUInt16(Unknown30, offset + 30); buffer.WriteUInt32(Unknown32, offset + 32); buffer.WriteInt32(Donation, offset + 36); buffer.WriteBool(IsOnline, offset + 40); buffer.WriteUInt32(Unknown44, offset + 44); nextoffset += 48; }
public static DataPacket GeneralDataA(uint UID, uint A, uint B, uint C, ushort Type, ushort E, ushort X, ushort Y) { DataPacket Packet = new DataPacket(45, 10010); Packet.WriteUInt32(UID, 4); Packet.WriteUInt32(A, 8); Packet.WriteUInt32(B, 12); Packet.WriteUInt32(C, 16); Packet.WriteUInt16(Type, 20); Packet.WriteUInt16(E, 22); Packet.WriteUInt16(X, 24); Packet.WriteUInt16(Y, 26); Packet.WriteUInt32(0, 28); Packet.WriteUInt32(0, 32); Packet.WriteByte(0, 36); return Packet; }