public static void Authentication(Client pClient, Packet pPacket) { string username; string password; byte[] macBytes = new byte[6]; if (!pPacket.ReadString(out username) || !pPacket.ReadString(out password) || !pPacket.ReadBytes(macBytes)) { pClient.Disconnect(); return; } Account account = null; using (DatabaseQuery query = Database.Query("SELECT * FROM account WHERE username=@username", new MySqlParameter("@username", username))) { if (!query.NextRow()) { SendAuthentication(pClient, EAuthenticationResult.Invalid); return; } account = new Account(query); } if (password != account.Password) { SendAuthentication(pClient, EAuthenticationResult.Incorrect); return; } if (Server.IsAccountOnline(account.Identifier) || Server.IsPendingPlayerLogin(account.Identifier)) { SendAuthentication(pClient, EAuthenticationResult.Online); return; } pClient.Account = account; Log.WriteLine(ELogLevel.Info, "[{0}] Authenticated {1}", pClient.Host, pClient.Account.Username); SendAuthentication(pClient, EAuthenticationResult.Ok); }