diff --git a/Client/Authentication/Network/AuthSocket.cs b/Client/Authentication/Network/AuthSocket.cs index 76d0279..6466079 100644 --- a/Client/Authentication/Network/AuthSocket.cs +++ b/Client/Authentication/Network/AuthSocket.cs @@ -272,10 +272,19 @@ void HandleRealmLogonChallenge() #endregion + + // get next command + ReadCommand(); break; } case AuthResult.NO_MATCH: Game.UI.LogLine("Unknown account name", LogLevel.Error); + failedAuthentications++; + if (failedAuthentications >= MAX_FAILED_AUTENTICATIONS) + { + Game.InvalidCredentials(); + return; + } break; case AuthResult.ACCOUNT_IN_USE: Game.UI.LogLine("Account already logged in", LogLevel.Error); @@ -285,8 +294,11 @@ void HandleRealmLogonChallenge() break; } - // get next command - ReadCommand(); + if (challenge.error != AuthResult.SUCCESS) + { + Game.Reconnect(); + return; + } } void HandleRealmLogonProof() @@ -445,6 +457,7 @@ public override bool Connect() catch (SocketException ex) { Game.UI.LogLine(string.Format("Auth socket failed. ({0})", (SocketError)ex.ErrorCode), LogLevel.Error); + Game.Reconnect(); return false; } diff --git a/Client/AutomatedGame.cs b/Client/AutomatedGame.cs index a5dd3c6..e465b09 100644 --- a/Client/AutomatedGame.cs +++ b/Client/AutomatedGame.cs @@ -197,7 +197,8 @@ public void ConnectTo(WorldServerInfo server) public virtual void Start() { // the initial socket is an AuthSocket - it will initiate its own asynch read - Running = socket.Connect(); + Running = true; + socket.Connect(); Task.Run(async () => { @@ -216,6 +217,16 @@ public override void Update() (socket as WorldSocket)?.HandlePackets(); + // Reconnect if it passed some time since last try of logging in + if (!Connected || !LoggedIn) + { + if (LastSentPacketTime < DateTime.Now.AddSeconds(-60) && LastSentPacketTime != default(DateTime)) + { + Reconnect(); + return; + } + } + if (World.SelectedCharacter == null) return;