protected override void DispatchPacket(Packet packet) { if (packet is AuthenticationAttempt_S2C) { AuthenticationAttempt_S2C auth = (AuthenticationAttempt_S2C)packet; if (auth.Result == AuthenticationAttempt_S2C.ResponseCode.OK) { m_target = GetRandomTarget(); Update(); } } }
private void Handle_AuthenticationAttempt(AuthenticationAttempt_C2S aa) { string hashedPassword = HashPassword(aa.Username, aa.Password); AccountModel account = m_accountRepository.GetAccountByUsernameAndPasswordHash(aa.Username, hashedPassword); AuthenticationAttempt_S2C response = new AuthenticationAttempt_S2C() { PlayerID = ID }; if (account != null) { bool alreadyOnline = false; if (s_loggedInAccounts.TryGetValue(account.AccountID, out alreadyOnline) && alreadyOnline) { Info("Username: {0} is already online but tried to log in", aa.Username); response.Result = AuthenticationAttempt_S2C.ResponseCode.AlreadyLoggedIn; } else { response.Result = LoadPlayer(account); if (response.Result == AuthenticationAttempt_S2C.ResponseCode.OK) { AccountID = account.AccountID; s_loggedInAccounts[account.AccountID] = true; response.X = (float)m_player.X; response.Y = (float)m_player.Y; response.ZoneID = m_player.Map; response.Stats = new Dictionary <int, float>(); foreach (var kvp in m_stats) { response.Stats.Add((int)kvp.Key, kvp.Value.StatValue); } ChangeZone(response.ZoneID); IsAuthenticated = true; } } } else { response.Result = AuthenticationAttempt_S2C.ResponseCode.BadLogin; Info("Login failed with username: {1} and password: {2}", ID, aa.Username, aa.Password); } Respond(aa, response); }