aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorShauren <shauren.trinity@gmail.com>2014-06-13 17:56:44 +0200
committerShauren <shauren.trinity@gmail.com>2014-06-13 17:56:44 +0200
commit31c987ad8a585be66223b867171240d91ff1b519 (patch)
tree4639bf54c2311dbf926c584a096940139f9a0314
parent3b940a27664555dada92f0f01927c7da8f1d51aa (diff)
Core/Battle.net: Fixed scripts linking by adding a completely unrelated function to a completely unrelated file in game project
-rw-r--r--src/server/game/Accounts/BattlenetAccountMgr.cpp23
-rw-r--r--src/server/game/Accounts/BattlenetAccountMgr.h1
-rw-r--r--src/server/game/Server/WorldSocket.cpp9
3 files changed, 28 insertions, 5 deletions
diff --git a/src/server/game/Accounts/BattlenetAccountMgr.cpp b/src/server/game/Accounts/BattlenetAccountMgr.cpp
index 4f4d78591f9..ca05ffd6141 100644
--- a/src/server/game/Accounts/BattlenetAccountMgr.cpp
+++ b/src/server/game/Accounts/BattlenetAccountMgr.cpp
@@ -118,3 +118,26 @@ std::string Battlenet::AccountMgr::CalculateShaPassHash(std::string const& name,
return ByteArrayToHexStr(sha.GetDigest(), sha.GetLength(), true);
}
+
+bool Battlenet::AccountMgr::GetAccountIdAndIndex(std::string const& account, uint32* battlenetAccountId, uint8* battlenetAccountIndex)
+{
+ Tokenizer tokens(account, '#');
+ if (tokens.size() != 2)
+ return false;
+
+ if (!battlenetAccountId)
+ return false;
+
+ *battlenetAccountId = atol(tokens[0]);
+ if (!*battlenetAccountId)
+ return false;
+
+ if (battlenetAccountIndex)
+ {
+ *battlenetAccountIndex = atol(tokens[1]);
+ if (!*battlenetAccountIndex)
+ return false;
+ }
+
+ return true;
+}
diff --git a/src/server/game/Accounts/BattlenetAccountMgr.h b/src/server/game/Accounts/BattlenetAccountMgr.h
index 1565c1aeee1..54a2841177d 100644
--- a/src/server/game/Accounts/BattlenetAccountMgr.h
+++ b/src/server/game/Accounts/BattlenetAccountMgr.h
@@ -38,6 +38,7 @@ namespace Battlenet
bool GetName(uint32 accountId, std::string& name);
std::string CalculateShaPassHash(std::string const& name, std::string const& password);
+ bool GetAccountIdAndIndex(std::string const& account, uint32* battlenetAccountId, uint8* battlenetAccountIndex);
}
}
diff --git a/src/server/game/Server/WorldSocket.cpp b/src/server/game/Server/WorldSocket.cpp
index 5905ec6a704..58299a7194c 100644
--- a/src/server/game/Server/WorldSocket.cpp
+++ b/src/server/game/Server/WorldSocket.cpp
@@ -45,6 +45,7 @@
#include "PacketLog.h"
#include "ScriptMgr.h"
#include "AccountMgr.h"
+#include "BattlenetAccountMgr.h"
#if defined(__GNUC__)
#pragma pack(1)
@@ -856,16 +857,14 @@ int WorldSocket::HandleAuthSession(WorldPacket& recvPacket)
// Get the account information from the realmd database
// 0 1 2 3 4 5 6 7 8
// SELECT id, sessionkey, last_ip, locked, expansion, mutetime, locale, recruiter, os FROM account WHERE username = ?
- size_t hashPos = account.find_last_of('#');
PreparedStatement* stmt;
uint32 battlenetAccountId = 0;
- if (hashPos != std::string::npos)
+ uint8 battlenetAccountIndex = 0;
+ if (Battlenet::AccountMgr::GetAccountIdAndIndex(account, &battlenetAccountId, &battlenetAccountIndex))
{
- Tokenizer tokens(account, '#', 2);
- battlenetAccountId = atol(tokens[0]);
stmt = LoginDatabase.GetPreparedStatement(LOGIN_SEL_ACCOUNT_INFO_BY_BNET);
stmt->setUInt32(0, battlenetAccountId);
- stmt->setUInt8(1, atol(tokens[1]));
+ stmt->setUInt8(1, battlenetAccountIndex);
}
else
{