diff options
author | Treeston <treeston.mmoc@gmail.com> | 2020-08-26 23:31:45 +0200 |
---|---|---|
committer | Shauren <shauren.trinity@gmail.com> | 2022-02-04 00:27:13 +0100 |
commit | be9dadc18949c6877f486eab9ee95237224a237e (patch) | |
tree | f34fcd28a0acf43d54c4bf853a24800090a2761b /src/server/scripts/Commands | |
parent | 7b88fd607e974843481d3055eb2eebc53c2a4b49 (diff) |
Common/Utilities: Centralize string -> T conversion in StringConvert.h (PR #25335)
(cherry picked from commit cd30e0b86ce6ee88386a91cebdf353fc55805c57)
Diffstat (limited to 'src/server/scripts/Commands')
-rw-r--r-- | src/server/scripts/Commands/cs_battlenet_account.cpp | 28 |
1 files changed, 7 insertions, 21 deletions
diff --git a/src/server/scripts/Commands/cs_battlenet_account.cpp b/src/server/scripts/Commands/cs_battlenet_account.cpp index 748cfbe1aee..c4f0dff6c01 100644 --- a/src/server/scripts/Commands/cs_battlenet_account.cpp +++ b/src/server/scripts/Commands/cs_battlenet_account.cpp @@ -68,45 +68,31 @@ public: } /// Create an account - static bool HandleAccountCreateCommand(ChatHandler* handler, char const* args) + static bool HandleAccountCreateCommand(ChatHandler* handler, std::string const& accountName, std::string const& password, Optional<bool> createGameAccount) { - if (!*args) - return false; - - ///- %Parse the command line arguments - char* accountName = strtok((char*)args, " "); - char* password = strtok(nullptr, " "); - if (!accountName || !password) - return false; - - if (!strchr(accountName, '@')) + if (accountName.find('@') == std::string::npos) { handler->SendSysMessage(LANG_ACCOUNT_INVALID_BNET_NAME); handler->SetSentErrorMessage(true); return false; } - char* createGameAccountParam = strtok(nullptr, " "); - bool createGameAccount = true; - if (createGameAccountParam) - createGameAccount = StringToBool(createGameAccountParam); - std::string gameAccountName; - switch (Battlenet::AccountMgr::CreateBattlenetAccount(std::string(accountName), std::string(password), createGameAccount, &gameAccountName)) + switch (Battlenet::AccountMgr::CreateBattlenetAccount(accountName, password, createGameAccount.value_or(true), &gameAccountName)) { case AccountOpResult::AOR_OK: { - if (createGameAccount) - handler->PSendSysMessage(LANG_ACCOUNT_CREATED_BNET_WITH_GAME, accountName, gameAccountName.c_str()); + if (createGameAccount == true) + handler->PSendSysMessage(LANG_ACCOUNT_CREATED_BNET_WITH_GAME, accountName.c_str(), gameAccountName.c_str()); else - handler->PSendSysMessage(LANG_ACCOUNT_CREATED_BNET, accountName); + handler->PSendSysMessage(LANG_ACCOUNT_CREATED_BNET, accountName.c_str()); if (handler->GetSession()) { TC_LOG_INFO("entities.player.character", "Account: %u (IP: %s) Character:[%s] (%s) created Battle.net account %s%s%s", handler->GetSession()->GetAccountId(), handler->GetSession()->GetRemoteAddress().c_str(), handler->GetSession()->GetPlayer()->GetName().c_str(), handler->GetSession()->GetPlayer()->GetGUID().ToString().c_str(), - accountName, createGameAccount ? " with game account " : "", createGameAccount ? gameAccountName.c_str() : ""); + accountName.c_str(), createGameAccount == true ? " with game account " : "", createGameAccount == true ? gameAccountName.c_str() : ""); } break; } |