diff options
author | Shauren <shauren.trinity@gmail.com> | 2014-11-10 01:19:24 +0100 |
---|---|---|
committer | Shauren <shauren.trinity@gmail.com> | 2014-11-10 01:19:24 +0100 |
commit | 0c27ffaa49c7e3e6880051ac74581cae51d83351 (patch) | |
tree | 341ff599888d4158edffd729b44f8932b52872f7 /src | |
parent | 2545804288dfac716ae474574d4ed47e71c500f1 (diff) |
Core/Commands: Battle.net account command changes
* All commands renamed from "battlenetaccount" to "bnetaccount"
* bnetaccount create now also creates and links initial game account
* Added new commands bnetaccount link/unlink to manage relations between existing accounts
Diffstat (limited to 'src')
-rw-r--r-- | src/server/bnetserver/Server/Session.cpp | 5 | ||||
-rw-r--r-- | src/server/game/Accounts/AccountMgr.cpp | 12 | ||||
-rw-r--r-- | src/server/game/Accounts/AccountMgr.h | 5 | ||||
-rw-r--r-- | src/server/game/Accounts/BattlenetAccountMgr.cpp | 95 | ||||
-rw-r--r-- | src/server/game/Accounts/BattlenetAccountMgr.h | 3 | ||||
-rw-r--r-- | src/server/game/Accounts/RBAC.h | 6 | ||||
-rw-r--r-- | src/server/game/Miscellaneous/Language.h | 7 | ||||
-rw-r--r-- | src/server/scripts/Commands/cs_battlenet_account.cpp | 131 | ||||
-rw-r--r-- | src/server/shared/Database/Implementation/LoginDatabase.cpp | 6 | ||||
-rw-r--r-- | src/server/shared/Database/Implementation/LoginDatabase.h | 2 |
10 files changed, 234 insertions, 38 deletions
diff --git a/src/server/bnetserver/Server/Session.cpp b/src/server/bnetserver/Server/Session.cpp index 8a23a839146..0a5a2de499a 100644 --- a/src/server/bnetserver/Server/Session.cpp +++ b/src/server/bnetserver/Server/Session.cpp @@ -771,8 +771,9 @@ bool Battlenet::Session::HandlePasswordModule(BitStream* dataStream, ServerPacke fields = result->Fetch(); std::ostringstream name; std::string originalName = fields[1].GetString(); - if (originalName.find('#') != std::string::npos) - name << "WoW" << uint32(fields[0].GetUInt8()); + std::size_t hashPos = originalName.find('#'); + if (hashPos != std::string::npos) + name << "WoW" << originalName.substr(hashPos + 1); else name << originalName; diff --git a/src/server/game/Accounts/AccountMgr.cpp b/src/server/game/Accounts/AccountMgr.cpp index d6985e2a1ad..41c1b0c7c87 100644 --- a/src/server/game/Accounts/AccountMgr.cpp +++ b/src/server/game/Accounts/AccountMgr.cpp @@ -33,7 +33,7 @@ AccountMgr::~AccountMgr() ClearRBAC(); } -AccountOpResult AccountMgr::CreateAccount(std::string username, std::string password, std::string email /*= ""*/) +AccountOpResult AccountMgr::CreateAccount(std::string username, std::string password, std::string email /*= ""*/, uint32 bnetAccountId /*= 0*/, uint8 bnetIndex /*= 0*/) { if (utf8length(username) > MAX_ACCOUNT_STR) return AccountOpResult::AOR_NAME_TOO_LONG; // username's too long @@ -51,6 +51,16 @@ AccountOpResult AccountMgr::CreateAccount(std::string username, std::string pass stmt->setString(1, CalculateShaPassHash(username, password)); stmt->setString(2, email); stmt->setString(3, email); + if (bnetAccountId && bnetIndex) + { + stmt->setUInt32(4, bnetAccountId); + stmt->setUInt8(5, bnetIndex); + } + else + { + stmt->setNull(4); + stmt->setNull(5); + } LoginDatabase.DirectExecute(stmt); // Enforce saving, otherwise AddGroup can fail diff --git a/src/server/game/Accounts/AccountMgr.h b/src/server/game/Accounts/AccountMgr.h index add00ec7feb..a3956ad8633 100644 --- a/src/server/game/Accounts/AccountMgr.h +++ b/src/server/game/Accounts/AccountMgr.h @@ -29,7 +29,8 @@ enum class AccountOpResult : uint8 AOR_EMAIL_TOO_LONG, AOR_NAME_ALREADY_EXIST, AOR_NAME_NOT_EXIST, - AOR_DB_INTERNAL_ERROR + AOR_DB_INTERNAL_ERROR, + AOR_ACCOUNT_BAD_LINK }; enum PasswordChangeSecurity @@ -62,7 +63,7 @@ class AccountMgr return &instance; } - AccountOpResult CreateAccount(std::string username, std::string password, std::string email = ""); + AccountOpResult CreateAccount(std::string username, std::string password, std::string email = "", uint32 bnetAccountId = 0, uint8 bnetIndex = 0); static AccountOpResult DeleteAccount(uint32 accountId); static AccountOpResult ChangeUsername(uint32 accountId, std::string newUsername, std::string newPassword); static AccountOpResult ChangePassword(uint32 accountId, std::string newPassword); diff --git a/src/server/game/Accounts/BattlenetAccountMgr.cpp b/src/server/game/Accounts/BattlenetAccountMgr.cpp index da71f02d7d2..6048a1e2b98 100644 --- a/src/server/game/Accounts/BattlenetAccountMgr.cpp +++ b/src/server/game/Accounts/BattlenetAccountMgr.cpp @@ -21,6 +21,8 @@ #include "Util.h" #include "SHA256.h" +using GameAccountMgr = AccountMgr; + AccountOpResult Battlenet::AccountMgr::CreateBattlenetAccount(std::string email, std::string password) { if (utf8length(email) > MAX_BNET_EMAIL_STR) @@ -38,8 +40,12 @@ AccountOpResult Battlenet::AccountMgr::CreateBattlenetAccount(std::string email, PreparedStatement* stmt = LoginDatabase.GetPreparedStatement(LOGIN_INS_BNET_ACCOUNT); stmt->setString(0, email); stmt->setString(1, CalculateShaPassHash(email, password)); - LoginDatabase.Execute(stmt); + LoginDatabase.DirectExecute(stmt); + uint32 newAccountId = GetId(email); + ASSERT(newAccountId); + + GameAccountMgr::instance()->CreateAccount(std::to_string(newAccountId) + "#1", password, email, newAccountId, 1); return AccountOpResult::AOR_OK; } @@ -62,20 +68,65 @@ AccountOpResult Battlenet::AccountMgr::ChangePassword(uint32 accountId, std::str return AccountOpResult::AOR_OK; } -uint32 Battlenet::AccountMgr::GetId(std::string const& username) +bool Battlenet::AccountMgr::CheckPassword(uint32 accountId, std::string password) { - PreparedStatement* stmt = LoginDatabase.GetPreparedStatement(LOGIN_SEL_BNET_ACCOUNT_ID_BY_EMAIL); - stmt->setString(0, username); - if (PreparedQueryResult result = LoginDatabase.Query(stmt)) - return (*result)[0].GetUInt32(); + std::string username; - return 0; + if (!GetName(accountId, username)) + return false; + + Utf8ToUpperOnlyLatin(username); + Utf8ToUpperOnlyLatin(password); + + PreparedStatement* stmt = LoginDatabase.GetPreparedStatement(LOGIN_SEL_BNET_CHECK_PASSWORD); + stmt->setUInt32(0, accountId); + stmt->setString(1, CalculateShaPassHash(username, password)); + + return LoginDatabase.Query(stmt) != nullptr; } -uint32 Battlenet::AccountMgr::GetIdByGameAccount(uint32 gameAccountId) +AccountOpResult Battlenet::AccountMgr::LinkWithGameAccount(std::string const& email, std::string const& gameAccountName) { - PreparedStatement* stmt = LoginDatabase.GetPreparedStatement(LOGIN_SEL_BNET_ACCOUNT_ID_BY_GAME_ACCOUNT); - stmt->setUInt32(0, gameAccountId); + uint32 bnetAccountId = GetId(email); + if (!bnetAccountId) + return AccountOpResult::AOR_NAME_NOT_EXIST; + + uint32 gameAccountId = GameAccountMgr::GetId(gameAccountName); + if (!gameAccountId) + return AccountOpResult::AOR_NAME_NOT_EXIST; + + if (GetIdByGameAccount(gameAccountId)) + return AccountOpResult::AOR_ACCOUNT_BAD_LINK; + + PreparedStatement* stmt = LoginDatabase.GetPreparedStatement(LOGIN_UPD_BNET_GAME_ACCOUNT_LINK); + stmt->setUInt32(0, bnetAccountId); + stmt->setUInt8(1, GetMaxIndex(bnetAccountId) + 1); + stmt->setUInt32(gameAccountId); + LoginDatabase.Execute(stmt); + return AccountOpResult::AOR_OK; +} + +AccountOpResult Battlenet::AccountMgr::UnlinkGameAccount(std::string const& gameAccountName) +{ + uint32 gameAccountId = GameAccountMgr::GetId(gameAccountName); + if (!gameAccountId) + return AccountOpResult::AOR_NAME_NOT_EXIST; + + if (!GetIdByGameAccount(gameAccountId)) + return AccountOpResult::AOR_ACCOUNT_BAD_LINK; + + PreparedStatement* stmt = LoginDatabase.GetPreparedStatement(LOGIN_UPD_BNET_GAME_ACCOUNT_LINK); + stmt->setNull(0); + stmt->setNull(1); + stmt->setUInt32(gameAccountId); + LoginDatabase.Execute(stmt); + return AccountOpResult::AOR_OK; +} + +uint32 Battlenet::AccountMgr::GetId(std::string const& username) +{ + PreparedStatement* stmt = LoginDatabase.GetPreparedStatement(LOGIN_SEL_BNET_ACCOUNT_ID_BY_EMAIL); + stmt->setString(0, username); if (PreparedQueryResult result = LoginDatabase.Query(stmt)) return (*result)[0].GetUInt32(); @@ -95,21 +146,25 @@ bool Battlenet::AccountMgr::GetName(uint32 accountId, std::string& name) return false; } -bool Battlenet::AccountMgr::CheckPassword(uint32 accountId, std::string password) +uint32 Battlenet::AccountMgr::GetIdByGameAccount(uint32 gameAccountId) { - std::string username; - - if (!GetName(accountId, username)) - return false; + PreparedStatement* stmt = LoginDatabase.GetPreparedStatement(LOGIN_SEL_BNET_ACCOUNT_ID_BY_GAME_ACCOUNT); + stmt->setUInt32(0, gameAccountId); + if (PreparedQueryResult result = LoginDatabase.Query(stmt)) + return (*result)[0].GetUInt32(); - Utf8ToUpperOnlyLatin(username); - Utf8ToUpperOnlyLatin(password); + return 0; +} - PreparedStatement* stmt = LoginDatabase.GetPreparedStatement(LOGIN_SEL_BNET_CHECK_PASSWORD); +uint8 Battlenet::AccountMgr::GetMaxIndex(uint32 accountId) +{ + PreparedStatement* stmt = LoginDatabase.GetPreparedStatement(LOGIN_SEL_BNET_MAX_ACCOUNT_INDEX); stmt->setUInt32(0, accountId); - stmt->setString(1, CalculateShaPassHash(username, password)); + PreparedQueryResult result = LoginDatabase.Query(stmt); + if (result) + return (*result)[0].GetUInt8(); - return LoginDatabase.Query(stmt) != nullptr; + return 0; } std::string Battlenet::AccountMgr::CalculateShaPassHash(std::string const& name, std::string const& password) diff --git a/src/server/game/Accounts/BattlenetAccountMgr.h b/src/server/game/Accounts/BattlenetAccountMgr.h index 1e0b7b78a99..07e9f684874 100644 --- a/src/server/game/Accounts/BattlenetAccountMgr.h +++ b/src/server/game/Accounts/BattlenetAccountMgr.h @@ -32,10 +32,13 @@ namespace Battlenet AccountOpResult CreateBattlenetAccount(std::string email, std::string password); AccountOpResult ChangePassword(uint32 accountId, std::string newPassword); bool CheckPassword(uint32 accountId, std::string password); + AccountOpResult LinkWithGameAccount(std::string const& email, std::string const& gameAccountName); + AccountOpResult UnlinkGameAccount(std::string const& gameAccountName); uint32 GetId(std::string const& username); bool GetName(uint32 accountId, std::string& name); uint32 GetIdByGameAccount(uint32 gameAccountId); + uint8 GetMaxIndex(uint32 accountId); std::string CalculateShaPassHash(std::string const& name, std::string const& password); } diff --git a/src/server/game/Accounts/RBAC.h b/src/server/game/Accounts/RBAC.h index e0c22f297ea..17c34a9b42a 100644 --- a/src/server/game/Accounts/RBAC.h +++ b/src/server/game/Accounts/RBAC.h @@ -117,9 +117,9 @@ enum RBACPermissions RBAC_PERM_COMMAND_BNET_ACCOUNT_PASSWORD = 211, RBAC_PERM_COMMAND_BNET_ACCOUNT_SET = 212, RBAC_PERM_COMMAND_BNET_ACCOUNT_SET_PASSWORD = 213, - // 214 - reuse - // 215 - reuse - // 216 - reuse + RBAC_PERM_COMMAND_BNET_ACCOUNT_LINK = 214, + RBAC_PERM_COMMAND_BNET_ACCOUNT_UNLINK = 215, + RBAC_PERM_COMMAND_BNET_ACCOUNT_CREATE_GAME = 216, RBAC_PERM_COMMAND_ACCOUNT = 217, RBAC_PERM_COMMAND_ACCOUNT_ADDON = 218, RBAC_PERM_COMMAND_ACCOUNT_CREATE = 219, diff --git a/src/server/game/Miscellaneous/Language.h b/src/server/game/Miscellaneous/Language.h index 41654f80dd4..a941dbd31ed 100644 --- a/src/server/game/Miscellaneous/Language.h +++ b/src/server/game/Miscellaneous/Language.h @@ -978,7 +978,12 @@ enum TrinityStrings LANG_GUILD_INFO_MOTD = 1182, LANG_GUILD_INFO_EXTRA_INFO = 1183, LANG_GUILD_INFO_LEVEL = 1184, - // Room for more level 3 1184-1199 not used + LANG_ACCOUNT_BNET_LINKED = 1185, + LANG_ACCOUNT_OR_BNET_DOES_NOT_EXIST = 1186, + LANG_ACCOUNT_ALREADY_LINKED = 1187, + LANG_ACCOUNT_BNET_UNLINKED = 1188, + LANG_ACCOUNT_BNET_NOT_LINKED = 1189, + // Room for more level 3 1190-1199 not used // Debug commands LANG_CINEMATIC_NOT_EXIST = 1200, diff --git a/src/server/scripts/Commands/cs_battlenet_account.cpp b/src/server/scripts/Commands/cs_battlenet_account.cpp index 06bd131150a..36e4d3fbf2c 100644 --- a/src/server/scripts/Commands/cs_battlenet_account.cpp +++ b/src/server/scripts/Commands/cs_battlenet_account.cpp @@ -44,17 +44,20 @@ public: static ChatCommand accountCommandTable[] = { - { "create", rbac::RBAC_PERM_COMMAND_BNET_ACCOUNT_CREATE, true, &HandleAccountCreateCommand, "", NULL }, - { "lock", rbac::RBAC_PERM_COMMAND_BNET_ACCOUNT, false, NULL, "", accountLockCommandTable }, - { "set", rbac::RBAC_PERM_COMMAND_BNET_ACCOUNT_SET, true, NULL, "", accountSetCommandTable }, - { "password", rbac::RBAC_PERM_COMMAND_BNET_ACCOUNT_PASSWORD, false, &HandleAccountPasswordCommand, "", NULL }, - { NULL, 0, false, NULL, "", NULL } + { "create", rbac::RBAC_PERM_COMMAND_BNET_ACCOUNT_CREATE, true, &HandleAccountCreateCommand, "", NULL }, + { "gameaccountcreate", rbac::RBAC_PERM_COMMAND_BNET_ACCOUNT_CREATE_GAME, true, &HandleGameAccountCreateCommand, "", NULL }, + { "lock", rbac::RBAC_PERM_COMMAND_BNET_ACCOUNT, false, NULL, "", accountLockCommandTable }, + { "set", rbac::RBAC_PERM_COMMAND_BNET_ACCOUNT_SET, true, NULL, "", accountSetCommandTable }, + { "password", rbac::RBAC_PERM_COMMAND_BNET_ACCOUNT_PASSWORD, false, &HandleAccountPasswordCommand, "", NULL }, + { "link", rbac::RBAC_PERM_COMMAND_BNET_ACCOUNT_LINK, true, &HandleAccountLinkCommand, "", NULL }, + { "unlink", rbac::RBAC_PERM_COMMAND_BNET_ACCOUNT_UNLINK, true, &HandleAccountUnlinkCommand, "", NULL }, + { NULL, 0, false, NULL, "", NULL } }; static ChatCommand commandTable[] = { - { "battlenetaccount", rbac::RBAC_PERM_COMMAND_BNET_ACCOUNT, true, NULL, "", accountCommandTable }, - { NULL, 0, false, NULL, "", NULL } + { "bnetaccount", rbac::RBAC_PERM_COMMAND_BNET_ACCOUNT, true, NULL, "", accountCommandTable }, + { NULL, 0, false, NULL, "", NULL } }; return commandTable; @@ -328,6 +331,120 @@ public: } return true; } + + static bool HandleAccountLinkCommand(ChatHandler* handler, char const* args) + { + Tokenizer tokens(args, ' ', 2); + if (tokens.size() != 2) + { + handler->SendSysMessage(LANG_CMD_SYNTAX); + handler->SetSentErrorMessage(true); + return false; + } + + std::string bnetAccountName = tokens[0]; + std::string gameAccountName = tokens[1]; + + switch (Battlenet::AccountMgr::LinkWithGameAccount(bnetAccountName, gameAccountName)) + { + case AccountOpResult::AOR_OK: + handler->PSendSysMessage(LANG_ACCOUNT_BNET_LINKED, bnetAccountName.c_str(), gameAccountName.c_str()); + break; + case AccountOpResult::AOR_NAME_NOT_EXIST: + handler->PSendSysMessage(LANG_ACCOUNT_OR_BNET_DOES_NOT_EXIST, bnetAccountName.c_str(), gameAccountName.c_str()); + handler->SetSentErrorMessage(true); + break; + case AccountOpResult::AOR_ACCOUNT_BAD_LINK: + handler->PSendSysMessage(LANG_ACCOUNT_ALREADY_LINKED, gameAccountName.c_str()); + handler->SetSentErrorMessage(true); + break; + } + + return true; + } + + static bool HandleAccountUnlinkCommand(ChatHandler* handler, char const* args) + { + if (!*args) + { + handler->SendSysMessage(LANG_CMD_SYNTAX); + handler->SetSentErrorMessage(true); + return false; + } + + std::string gameAccountName = args; + + switch (Battlenet::AccountMgr::UnlinkGameAccount(gameAccountName)) + { + case AccountOpResult::AOR_OK: + handler->PSendSysMessage(LANG_ACCOUNT_BNET_UNLINKED, gameAccountName.c_str()); + break; + case AccountOpResult::AOR_NAME_NOT_EXIST: + handler->PSendSysMessage(LANG_ACCOUNT_NOT_EXIST, gameAccountName.c_str()); + handler->SetSentErrorMessage(true); + break; + case AccountOpResult::AOR_ACCOUNT_BAD_LINK: + handler->PSendSysMessage(LANG_ACCOUNT_BNET_NOT_LINKED, gameAccountName.c_str()); + handler->SetSentErrorMessage(true); + break; + } + + return true; + } + + static bool HandleGameAccountCreateCommand(ChatHandler* handler, char const* args) + { + if (!*args) + { + handler->SendSysMessage(LANG_CMD_SYNTAX); + handler->SetSentErrorMessage(true); + return false; + } + + std::string bnetAccountName = args; + uint32 accountId = Battlenet::AccountMgr::GetId(bnetAccountName); + if (!accountId) + { + handler->PSendSysMessage(LANG_ACCOUNT_NOT_EXIST, bnetAccountName.c_str()); + handler->SetSentErrorMessage(true); + return false; + } + + 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)) + { + case AccountOpResult::AOR_OK: + handler->PSendSysMessage(LANG_ACCOUNT_CREATED, accountName.c_str()); + if (handler->GetSession()) + { + TC_LOG_INFO("entities.player.character", "Account: %u (IP: %s) Character:[%s] (%s) created Account %s (Email: '%s')", + handler->GetSession()->GetAccountId(), handler->GetSession()->GetRemoteAddress().c_str(), + handler->GetSession()->GetPlayer()->GetName().c_str(), handler->GetSession()->GetPlayer()->GetGUID().ToString().c_str(), + accountName.c_str(), bnetAccountName.c_str()); + } + break; + case AccountOpResult::AOR_NAME_TOO_LONG: + handler->SendSysMessage(LANG_ACCOUNT_TOO_LONG); + handler->SetSentErrorMessage(true); + return false; + case AccountOpResult::AOR_NAME_ALREADY_EXIST: + handler->SendSysMessage(LANG_ACCOUNT_ALREADY_EXIST); + handler->SetSentErrorMessage(true); + return false; + case AccountOpResult::AOR_DB_INTERNAL_ERROR: + handler->PSendSysMessage(LANG_ACCOUNT_NOT_CREATED_SQL_ERROR, accountName.c_str()); + handler->SetSentErrorMessage(true); + return false; + default: + handler->PSendSysMessage(LANG_ACCOUNT_NOT_CREATED, accountName.c_str()); + handler->SetSentErrorMessage(true); + return false; + } + + return true; + } }; void AddSC_battlenet_account_commandscript() diff --git a/src/server/shared/Database/Implementation/LoginDatabase.cpp b/src/server/shared/Database/Implementation/LoginDatabase.cpp index bfdd39fdd3e..4d0d4df2003 100644 --- a/src/server/shared/Database/Implementation/LoginDatabase.cpp +++ b/src/server/shared/Database/Implementation/LoginDatabase.cpp @@ -57,7 +57,7 @@ void LoginDatabaseConnection::DoPrepareStatements() PrepareStatement(LOGIN_DEL_REALM_CHARACTERS, "DELETE FROM realmcharacters WHERE acctid = ?", CONNECTION_ASYNC); PrepareStatement(LOGIN_INS_REALM_CHARACTERS, "INSERT INTO realmcharacters (numchars, acctid, realmid) VALUES (?, ?, ?)", CONNECTION_ASYNC); PrepareStatement(LOGIN_SEL_SUM_REALM_CHARACTERS, "SELECT SUM(numchars) FROM realmcharacters WHERE acctid = ?", CONNECTION_ASYNC); - PrepareStatement(LOGIN_INS_ACCOUNT, "INSERT INTO account(username, sha_pass_hash, reg_mail, email, joindate) VALUES(?, ?, ?, ?, NOW())", CONNECTION_SYNCH); + PrepareStatement(LOGIN_INS_ACCOUNT, "INSERT INTO account(username, sha_pass_hash, reg_mail, email, joindate, battlenet_account, battlenet_index) VALUES(?, ?, ?, ?, NOW(), ?, ?)", CONNECTION_SYNCH); PrepareStatement(LOGIN_INS_REALM_CHARACTERS_INIT, "INSERT INTO realmcharacters (realmid, acctid, numchars) SELECT realmlist.id, account.id, 0 FROM realmlist, account LEFT JOIN realmcharacters ON acctid=account.id WHERE acctid IS NULL", CONNECTION_ASYNC); PrepareStatement(LOGIN_UPD_EXPANSION, "UPDATE account SET expansion = ? WHERE id = ?", CONNECTION_ASYNC); PrepareStatement(LOGIN_UPD_ACCOUNT_LOCK, "UPDATE account SET locked = ? WHERE id = ?", CONNECTION_ASYNC); @@ -129,7 +129,7 @@ void LoginDatabaseConnection::DoPrepareStatements() PrepareStatement(LOGIN_UPD_BNET_FAILED_LOGINS, "UPDATE battlenet_accounts SET failed_logins = failed_logins + 1 WHERE email = ?", CONNECTION_ASYNC); PrepareStatement(LOGIN_UPD_BNET_LAST_LOGIN_INFO, "UPDATE battlenet_accounts SET last_ip = ?, last_login = NOW(), locale = ?, failed_logins = 0, os = ? WHERE id = ?", CONNECTION_ASYNC); PrepareStatement(LOGIN_SEL_BNET_CHARACTER_COUNTS, "SELECT rc.numchars, r.id, r.Region, r.Battlegroup, r.gamebuild FROM realmcharacters rc INNER JOIN realmlist r ON rc.realmid = r.id WHERE rc.acctid = ?", CONNECTION_SYNCH); - PrepareStatement(LOGIN_INS_BNET_ACCOUNT, "INSERT INTO battlenet_accounts (`email`,`sha_pass_hash`) VALUES (?, ?)", CONNECTION_ASYNC); + PrepareStatement(LOGIN_INS_BNET_ACCOUNT, "INSERT INTO battlenet_accounts (`email`,`sha_pass_hash`) VALUES (?, ?)", CONNECTION_SYNCH); PrepareStatement(LOGIN_SEL_BNET_ACCOUNT_EMAIL_BY_ID, "SELECT email FROM battlenet_accounts WHERE id = ?", CONNECTION_SYNCH); PrepareStatement(LOGIN_SEL_BNET_ACCOUNT_ID_BY_EMAIL, "SELECT id FROM battlenet_accounts WHERE email = ?", CONNECTION_SYNCH); PrepareStatement(LOGIN_UPD_BNET_PASSWORD, "UPDATE battlenet_accounts SET v = '', s = '', sha_pass_hash = ? WHERE id = ?", CONNECTION_ASYNC); @@ -137,6 +137,8 @@ void LoginDatabaseConnection::DoPrepareStatements() PrepareStatement(LOGIN_UPD_BNET_ACCOUNT_LOCK, "UPDATE battlenet_accounts SET locked = ? WHERE id = ?", CONNECTION_ASYNC); PrepareStatement(LOGIN_UPD_BNET_ACCOUNT_LOCK_CONTRY, "UPDATE battlenet_accounts SET lock_country = ? WHERE id = ?", CONNECTION_ASYNC); PrepareStatement(LOGIN_SEL_BNET_ACCOUNT_ID_BY_GAME_ACCOUNT, "SELECT battlenet_account FROM account WHERE id = ?", CONNECTION_SYNCH); + PrepareStatement(LOGIN_UPD_BNET_GAME_ACCOUNT_LINK, "UPDATE account SET battlenet_account = ?, battlenet_index = ? WHERE id = ?", CONNECTION_ASYNC); + PrepareStatement(LOGIN_SEL_BNET_MAX_ACCOUNT_INDEX, "SELECT MAX(battlenet_index) FROM account WHERE battlenet_account = ?", CONNECTION_SYNCH); PrepareStatement(LOGIN_SEL_LAST_CHAR_UNDELETE, "SELECT LastCharacterUndelete FROM battlenet_accounts WHERE Id = ?", CONNECTION_ASYNC); PrepareStatement(LOGIN_UPD_LAST_CHAR_UNDELETE, "UPDATE battlenet_accounts SET LastCharacterUndelete = UNIX_TIMESTAMP() WHERE Id = ?", CONNECTION_ASYNC); diff --git a/src/server/shared/Database/Implementation/LoginDatabase.h b/src/server/shared/Database/Implementation/LoginDatabase.h index 07653263ef9..3667b65e885 100644 --- a/src/server/shared/Database/Implementation/LoginDatabase.h +++ b/src/server/shared/Database/Implementation/LoginDatabase.h @@ -153,6 +153,8 @@ enum LoginDatabaseStatements LOGIN_UPD_BNET_ACCOUNT_LOCK, LOGIN_UPD_BNET_ACCOUNT_LOCK_CONTRY, LOGIN_SEL_BNET_ACCOUNT_ID_BY_GAME_ACCOUNT, + LOGIN_UPD_BNET_GAME_ACCOUNT_LINK, + LOGIN_SEL_BNET_MAX_ACCOUNT_INDEX, LOGIN_SEL_LAST_CHAR_UNDELETE, LOGIN_UPD_LAST_CHAR_UNDELETE, |