From db83da417a6aa32962df5cfe4f9ce5d6b0ea5ada Mon Sep 17 00:00:00 2001 From: hondacrx Date: Thu, 7 Jul 2022 13:44:01 -0400 Subject: [PATCH] Fixes bnet account create command. --- Source/Game/Accounts/BNetAccountManager.cs | 4 +-- Source/Game/Chat/CommandArgs.cs | 27 +++++-------------- .../Game/Chat/Commands/BNetAccountCommands.cs | 4 +-- Source/Game/Chat/Commands/DebugCommands.cs | 2 +- 4 files changed, 12 insertions(+), 25 deletions(-) diff --git a/Source/Game/Accounts/BNetAccountManager.cs b/Source/Game/Accounts/BNetAccountManager.cs index b860231db..3f045aa78 100644 --- a/Source/Game/Accounts/BNetAccountManager.cs +++ b/Source/Game/Accounts/BNetAccountManager.cs @@ -30,10 +30,10 @@ namespace Game { gameAccountName = ""; - if (email.Length > 320) + if (email.IsEmpty() || email.Length > 320) return AccountOpResult.NameTooLong; - if (password.Length > 16) + if (password.IsEmpty() || password.Length > 16) return AccountOpResult.PassTooLong; if (GetId(email) != 0) diff --git a/Source/Game/Chat/CommandArgs.cs b/Source/Game/Chat/CommandArgs.cs index 1528abf07..12e3fd882 100644 --- a/Source/Game/Chat/CommandArgs.cs +++ b/Source/Game/Chat/CommandArgs.cs @@ -30,28 +30,15 @@ namespace Game.Chat { List arguments = new(); arguments.Add(handler); + for (var i = 1; i < parameterTypes.Length; i++) + arguments.Add(default); - //for each arg we need to see if its a: - //1: hyperlink - //2: Optional arg - //3: reg arg. - int index = 1; - while (index < parameterTypes.Length) + for (var i = 1; i < parameterTypes.Length; i++) { - int oldPos = args.GetCurrentPosition(); + if (!ParseArgument(out dynamic value, parameterTypes[i], args)) + break; - if (ParseArgument(out dynamic value, parameterTypes[index], args)) - index++; - - if (args.IsAtEnd() && index < parameterTypes.Length) - { - //We found a optional arg and we dont have the correct amount of args - args.SetCurrentPosition(oldPos); - arguments.Add(default); - index++; - } - else - arguments.Add(value); + arguments[i] = value; } return arguments.ToArray(); @@ -123,7 +110,7 @@ namespace Game.Chat default: return false; } - return true; + break; default: return false; } diff --git a/Source/Game/Chat/Commands/BNetAccountCommands.cs b/Source/Game/Chat/Commands/BNetAccountCommands.cs index c7dd29b18..a02d9e077 100644 --- a/Source/Game/Chat/Commands/BNetAccountCommands.cs +++ b/Source/Game/Chat/Commands/BNetAccountCommands.cs @@ -28,7 +28,7 @@ namespace Game.Chat.Commands [Command("create", RBACPermissions.CommandBnetAccountCreate, true)] static bool HandleAccountCreateCommand(CommandHandler handler, string accountName, string password, bool? createGameAccount) { - if (!accountName.Contains('@')) + if (accountName.IsEmpty() || !accountName.Contains('@')) { handler.SendSysMessage(CypherStrings.AccountInvalidBnetName); return false; @@ -38,7 +38,7 @@ namespace Game.Chat.Commands switch (Global.BNetAccountMgr.CreateBattlenetAccount(accountName, password, createGameAccount.GetValueOrDefault(true), out gameAccountName)) { case AccountOpResult.Ok: - if (createGameAccount.Value) + if (createGameAccount.HasValue && createGameAccount.Value) handler.SendSysMessage(CypherStrings.AccountCreatedBnetWithGame, accountName, gameAccountName); else handler.SendSysMessage(CypherStrings.AccountCreated, accountName); diff --git a/Source/Game/Chat/Commands/DebugCommands.cs b/Source/Game/Chat/Commands/DebugCommands.cs index 866dfc310..b1d96c47f 100644 --- a/Source/Game/Chat/Commands/DebugCommands.cs +++ b/Source/Game/Chat/Commands/DebugCommands.cs @@ -879,7 +879,7 @@ namespace Game.Chat return false; } - if (state == 0) + if (!state.HasValue) { // reset all states for (AuraStateType s = 0; s < AuraStateType.Max; ++s)