From 7424e0591e19cdf2ce9e439e432ea74005e564cb Mon Sep 17 00:00:00 2001 From: jackpoz Date: Sat, 10 Aug 2019 17:08:20 +0200 Subject: [PATCH] Log if character creation fails without removing the bot anymore --- BotFarm/BotFactory.cs | 1 - BotFarm/BotGame.cs | 20 +++++++------------- Client/AutomatedGame.cs | 7 ++++++- Client/World/Network/AuthResponse.cs | 2 +- 4 files changed, 14 insertions(+), 16 deletions(-) diff --git a/BotFarm/BotFactory.cs b/BotFarm/BotFactory.cs index c12401e..08c77b2 100644 --- a/BotFarm/BotFactory.cs +++ b/BotFarm/BotFactory.cs @@ -139,7 +139,6 @@ public BotGame CreateBot(bool startBot) Settings.Default.RealmID, 0, botBehavior); - game.SettingUp = true; if (startBot) game.Start(); botInfos.Add(new BotInfo(username, password, botBehavior.Name)); diff --git a/BotFarm/BotGame.cs b/BotFarm/BotGame.cs index 5e502a9..499ecf8 100644 --- a/BotFarm/BotGame.cs +++ b/BotFarm/BotGame.cs @@ -20,12 +20,6 @@ namespace BotFarm { class BotGame : AutomatedGame { - public bool SettingUp - { - get; - set; - } - public BotBehaviorSettings Behavior { get; @@ -202,13 +196,13 @@ public override void Start() public override void NoCharactersFound() { - if (!SettingUp) - { - Log("Removing current bot because there are no characters"); - BotFactory.Instance.RemoveBot(this); - } - else - CreateCharacter(Race.Human, Class.Priest); + CreateCharacter(Race.Human, Class.Priest); + } + + public override void CharacterCreationFailed(CommandDetail result) + { +#warning ToDo: create a character with a different name + Log($"Bot {Username} failed creating a character with error {result.ToString()}", LogLevel.Error); } public override void InvalidCredentials() diff --git a/Client/AutomatedGame.cs b/Client/AutomatedGame.cs index 0937ae1..ffe779a 100644 --- a/Client/AutomatedGame.cs +++ b/Client/AutomatedGame.cs @@ -420,6 +420,11 @@ public async Task Dispose() public virtual void NoCharactersFound() { } + public virtual void CharacterCreationFailed(CommandDetail result) + { + NoCharactersFound(); + } + public virtual void InvalidCredentials() { } @@ -818,7 +823,7 @@ protected void HandleCharCreate(InPacket packet) if (response == CommandDetail.CHAR_CREATE_SUCCESS) SendPacket(new OutPacket(WorldCommand.CMSG_CHAR_ENUM)); else - NoCharactersFound(); + CharacterCreationFailed(response); } [PacketHandler(WorldCommand.SMSG_LOGOUT_RESPONSE)] diff --git a/Client/World/Network/AuthResponse.cs b/Client/World/Network/AuthResponse.cs index c5e2f05..5bcbd3a 100644 --- a/Client/World/Network/AuthResponse.cs +++ b/Client/World/Network/AuthResponse.cs @@ -5,7 +5,7 @@ namespace Client.World.Network { - enum CommandDetail : byte + public enum CommandDetail : byte { AUTH_OK = 12, AUTH_FAILED = 13,