Skip to content

Commit

Permalink
Core/Commands: Slightly improve output of bnetaccount create command
Browse files Browse the repository at this point in the history
Ref #18002
  • Loading branch information
Shauren committed Sep 26, 2016
1 parent e22c800 commit 660aa05
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 8 deletions.
4 changes: 4 additions & 0 deletions sql/updates/world/6.x/2016_09_26_00_world.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
DELETE FROM `trinity_string` WHERE `entry` IN (1032, 1033);
INSERT INTO `trinity_string` (`entry`, `content_default`) VALUES
(1032, 'Battle.net account created: %s with game account %s'),
(1033, 'Battle.net account created: %s');
7 changes: 5 additions & 2 deletions src/server/game/Accounts/BattlenetAccountMgr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@

using GameAccountMgr = AccountMgr;

AccountOpResult Battlenet::AccountMgr::CreateBattlenetAccount(std::string email, std::string password, bool withGameAccount /*= true*/)
AccountOpResult Battlenet::AccountMgr::CreateBattlenetAccount(std::string email, std::string password, bool withGameAccount, std::string* gameAccountName)
{
if (utf8length(email) > MAX_BNET_EMAIL_STR)
return AccountOpResult::AOR_NAME_TOO_LONG;
Expand All @@ -46,7 +46,10 @@ AccountOpResult Battlenet::AccountMgr::CreateBattlenetAccount(std::string email,
ASSERT(newAccountId);

if (withGameAccount)
GameAccountMgr::instance()->CreateAccount(std::to_string(newAccountId) + "#1", password, email, newAccountId, 1);
{
*gameAccountName = std::to_string(newAccountId) + "#1";
GameAccountMgr::instance()->CreateAccount(*gameAccountName, password, email, newAccountId, 1);
}

return AccountOpResult::AOR_OK;
}
Expand Down
2 changes: 1 addition & 1 deletion src/server/game/Accounts/BattlenetAccountMgr.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ namespace Battlenet
{
namespace AccountMgr
{
TC_GAME_API AccountOpResult CreateBattlenetAccount(std::string email, std::string password, bool withGameAccount = true);
TC_GAME_API AccountOpResult CreateBattlenetAccount(std::string email, std::string password, bool withGameAccount, std::string* gameAccountName);
TC_GAME_API AccountOpResult ChangePassword(uint32 accountId, std::string newPassword);
TC_GAME_API bool CheckPassword(uint32 accountId, std::string password);
TC_GAME_API AccountOpResult LinkWithGameAccount(std::string const& email, std::string const& gameAccountName);
Expand Down
5 changes: 4 additions & 1 deletion src/server/game/Miscellaneous/Language.h
Original file line number Diff line number Diff line change
Expand Up @@ -899,7 +899,10 @@ enum TrinityStrings
LANG_SQLDRIVER_QUERY_LOGGING_DISABLED = 1028,
LANG_ACCOUNT_INVALID_BNET_NAME = 1029,
LANG_ACCOUNT_USE_BNET_COMMANDS = 1030,
// Room for more level 4 1031-1099 not used
LANG_ACCOUNT_PASS_TOO_LONG = 1031,
LANG_ACCOUNT_CREATED_BNET_WITH_GAME = 1032,
LANG_ACCOUNT_CREATED_BNET = 1033,
// Room for more level 4 1034-1099 not used

// Level 3 (continue)
LANG_ACCOUNT_SETADDON = 1100,
Expand Down
15 changes: 11 additions & 4 deletions src/server/scripts/Commands/cs_battlenet_account.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -84,18 +84,25 @@ class battlenet_account_commandscript : public CommandScript
if (createGameAccountParam)
createGameAccount = StringToBool(createGameAccountParam);

switch (Battlenet::AccountMgr::CreateBattlenetAccount(std::string(accountName), std::string(password), createGameAccount))
std::string gameAccountName;
switch (Battlenet::AccountMgr::CreateBattlenetAccount(std::string(accountName), std::string(password), createGameAccount, &gameAccountName))
{
case AccountOpResult::AOR_OK:
handler->PSendSysMessage(LANG_ACCOUNT_CREATED, accountName);
{
if (createGameAccount)
handler->PSendSysMessage(LANG_ACCOUNT_CREATED_BNET_WITH_GAME, accountName, gameAccountName.c_str());
else
handler->PSendSysMessage(LANG_ACCOUNT_CREATED_BNET, accountName);

if (handler->GetSession())
{
TC_LOG_INFO("entities.player.character", "Battle.net account: %u (IP: %s) Character:[%s] (%s) created Account %s",
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);
accountName, createGameAccount ? " with game account " : "", createGameAccount ? gameAccountName.c_str() : "");
}
break;
}
case AccountOpResult::AOR_NAME_TOO_LONG:
handler->SendSysMessage(LANG_ACCOUNT_TOO_LONG);
handler->SetSentErrorMessage(true);
Expand Down

0 comments on commit 660aa05

Please sign in to comment.