diff options
author | Shauren <shauren.trinity@gmail.com> | 2015-01-17 20:02:19 +0100 |
---|---|---|
committer | Shauren <shauren.trinity@gmail.com> | 2015-01-17 20:03:39 +0100 |
commit | 58d75eda3a0fea8f64d434adb7707b2dfd953089 (patch) | |
tree | 82d3bf88772319e902c82f37df35c8eee53ae043 /src | |
parent | 17039cd92255d85edff14171397a326c6eeffd06 (diff) |
Core/Commands: Added "createGameAccount" argument to .bnetaccount create command (default true) to opt out of creating the initial game account
Diffstat (limited to 'src')
-rw-r--r-- | src/server/game/Accounts/BattlenetAccountMgr.cpp | 6 | ||||
-rw-r--r-- | src/server/game/Accounts/BattlenetAccountMgr.h | 2 | ||||
-rw-r--r-- | src/server/scripts/Commands/cs_battlenet_account.cpp | 14 | ||||
-rw-r--r-- | src/server/shared/Utilities/Util.cpp | 7 | ||||
-rw-r--r-- | src/server/shared/Utilities/Util.h | 2 |
5 files changed, 26 insertions, 5 deletions
diff --git a/src/server/game/Accounts/BattlenetAccountMgr.cpp b/src/server/game/Accounts/BattlenetAccountMgr.cpp index 88ebb000b5b..3241c6eb5a2 100644 --- a/src/server/game/Accounts/BattlenetAccountMgr.cpp +++ b/src/server/game/Accounts/BattlenetAccountMgr.cpp @@ -23,7 +23,7 @@ using GameAccountMgr = AccountMgr; -AccountOpResult Battlenet::AccountMgr::CreateBattlenetAccount(std::string email, std::string password) +AccountOpResult Battlenet::AccountMgr::CreateBattlenetAccount(std::string email, std::string password, bool withGameAccount /*= true*/) { if (utf8length(email) > MAX_BNET_EMAIL_STR) return AccountOpResult::AOR_NAME_TOO_LONG; @@ -45,7 +45,9 @@ AccountOpResult Battlenet::AccountMgr::CreateBattlenetAccount(std::string email, uint32 newAccountId = GetId(email); ASSERT(newAccountId); - GameAccountMgr::instance()->CreateAccount(std::to_string(newAccountId) + "#1", password, email, newAccountId, 1); + if (withGameAccount) + GameAccountMgr::instance()->CreateAccount(std::to_string(newAccountId) + "#1", password, email, newAccountId, 1); + return AccountOpResult::AOR_OK; } diff --git a/src/server/game/Accounts/BattlenetAccountMgr.h b/src/server/game/Accounts/BattlenetAccountMgr.h index 120bee18e13..7601cbc4e53 100644 --- a/src/server/game/Accounts/BattlenetAccountMgr.h +++ b/src/server/game/Accounts/BattlenetAccountMgr.h @@ -29,7 +29,7 @@ namespace Battlenet { namespace AccountMgr { - AccountOpResult CreateBattlenetAccount(std::string email, std::string password); + AccountOpResult CreateBattlenetAccount(std::string email, std::string password, bool withGameAccount = true); AccountOpResult ChangePassword(uint32 accountId, std::string newPassword); bool CheckPassword(uint32 accountId, std::string password); AccountOpResult LinkWithGameAccount(std::string const& email, std::string const& gameAccountName); diff --git a/src/server/scripts/Commands/cs_battlenet_account.cpp b/src/server/scripts/Commands/cs_battlenet_account.cpp index f92f541c0a2..767a75f0b36 100644 --- a/src/server/scripts/Commands/cs_battlenet_account.cpp +++ b/src/server/scripts/Commands/cs_battlenet_account.cpp @@ -21,6 +21,7 @@ #include "Language.h" #include "Player.h" #include "ScriptMgr.h" +#include "Util.h" class battlenet_account_commandscript : public CommandScript { @@ -84,7 +85,12 @@ public: return false; } - switch (Battlenet::AccountMgr::CreateBattlenetAccount(std::string(accountName), std::string(password))) + char* createGameAccountParam = strtok(NULL, " "); + bool createGameAccount = true; + if (createGameAccountParam) + createGameAccount = StringToBool(createGameAccountParam); + + switch (Battlenet::AccountMgr::CreateBattlenetAccount(std::string(accountName), std::string(password), createGameAccount)) { case AccountOpResult::AOR_OK: handler->PSendSysMessage(LANG_ACCOUNT_CREATED, accountName); @@ -417,7 +423,11 @@ public: uint8 index = Battlenet::AccountMgr::GetMaxIndex(accountId) + 1; std::string accountName = std::to_string(accountId) + '#' + std::to_string(uint32(index)); - switch (sAccountMgr->CreateAccount(accountName, "DUMMY", bnetAccountName, accountId, index)) + // Generate random hex string for password, these accounts must not be logged on with GRUNT + BigNumber randPassword; + randPassword.SetRand(8 * 16); + + switch (sAccountMgr->CreateAccount(accountName, ByteArrayToHexStr(randPassword.AsByteArray().get(), randPassword.GetNumBytes()), bnetAccountName, accountId, index)) { case AccountOpResult::AOR_OK: handler->PSendSysMessage(LANG_ACCOUNT_CREATED, accountName.c_str()); diff --git a/src/server/shared/Utilities/Util.cpp b/src/server/shared/Utilities/Util.cpp index ff54237d10a..9a3d612a54b 100644 --- a/src/server/shared/Utilities/Util.cpp +++ b/src/server/shared/Utilities/Util.cpp @@ -24,6 +24,7 @@ #include "Errors.h" // for ASSERT #include <stdarg.h> #include <boost/thread/tss.hpp> +#include <boost/algorithm/string/case_conv.hpp> #if COMPILER == COMPILER_GNU #include <sys/socket.h> @@ -605,3 +606,9 @@ void HexStrToByteArray(std::string const& str, uint8* out, bool reverse /*= fals out[j++] = strtoul(buffer, NULL, 16); } } + +bool StringToBool(std::string const& str) +{ + std::string lowerStr = boost::algorithm::to_lower_copy(str); + return lowerStr == "1" || lowerStr == "true" || lowerStr == "yes"; +} diff --git a/src/server/shared/Utilities/Util.h b/src/server/shared/Utilities/Util.h index 4e613ecd170..26e7ef76d04 100644 --- a/src/server/shared/Utilities/Util.h +++ b/src/server/shared/Utilities/Util.h @@ -370,6 +370,8 @@ uint32 CreatePIDFile(const std::string& filename); std::string ByteArrayToHexStr(uint8 const* bytes, uint32 length, bool reverse = false); void HexStrToByteArray(std::string const& str, uint8* out, bool reverse = false); +bool StringToBool(std::string const& str); + // simple class for not-modifyable list template <typename T> class HookList |