aboutsummaryrefslogtreecommitdiff
path: root/src/server/authserver
diff options
context:
space:
mode:
authorShauren <shauren.trinity@gmail.com>2014-06-08 14:54:37 +0200
committerShauren <shauren.trinity@gmail.com>2014-06-08 14:54:37 +0200
commit05c0524bf3d97ba29496fa13e93acd3b8d7d37a4 (patch)
treec7781f1cedac93cd2f7dba51bd716dcd759699fa /src/server/authserver
parent372f043a68788f1903232392546c0d386b9fc248 (diff)
Core/Battle.net: Refactored handling multiple game accounts
Diffstat (limited to 'src/server/authserver')
-rw-r--r--src/server/authserver/Server/BattlenetPackets.cpp6
-rw-r--r--src/server/authserver/Server/BattlenetPackets.h4
-rw-r--r--src/server/authserver/Server/BattlenetSocket.cpp30
-rw-r--r--src/server/authserver/Server/BattlenetSocket.h1
4 files changed, 29 insertions, 12 deletions
diff --git a/src/server/authserver/Server/BattlenetPackets.cpp b/src/server/authserver/Server/BattlenetPackets.cpp
index 9997ea8d259..6a8e09090ef 100644
--- a/src/server/authserver/Server/BattlenetPackets.cpp
+++ b/src/server/authserver/Server/BattlenetPackets.cpp
@@ -202,7 +202,7 @@ void Battlenet::AuthComplete::Write()
_stream.WriteString(FirstName, 8); // First name
_stream.WriteString(LastName, 8); // Last name - not set for WoW
- _stream.Write(GameAccountId, 32);
+ _stream.Write(AccountId, 32);
_stream.Write(Region, 8);
_stream.Write(0, 64);
@@ -236,7 +236,7 @@ std::string Battlenet::AuthComplete::ToString() const
{
std::ostringstream stream;
stream << "Battlenet::AuthComplete AuthResult " << Result << " PingTimeout " << PingTimeout << " Threshold " << Threshold << " Rate " << Rate
- << " FirstName " << FirstName << " LastName " << LastName << " GameAccountId " << GameAccountId << " GameAccountName " << GameAccountName
+ << " FirstName " << FirstName << " LastName " << LastName << " AccountId " << AccountId << " Region " << uint32(Region) << " GameAccountName " << GameAccountName
<< " GameAccountFlags " << GameAccountFlags << " Modules " << Modules.size();
for (ModuleInfo const* module : Modules)
@@ -441,7 +441,7 @@ void Battlenet::RealmJoinResult::Write()
std::string Battlenet::RealmJoinResult::ToString() const
{
std::ostringstream stream;
- stream << "Battlenet::RealmJoinResult ServerSeed " << ServerSeed << " Addresses (IPv4)" << IPv4.size();
+ stream << "Battlenet::RealmJoinResult ServerSeed " << ServerSeed << " IPv4 Addresses " << IPv4.size();
for (ACE_INET_Addr const& addr : IPv4)
stream << std::endl << "Battlenet::RealmJoinResult::Address " << GetAddressString(addr);
diff --git a/src/server/authserver/Server/BattlenetPackets.h b/src/server/authserver/Server/BattlenetPackets.h
index 3fa628c2ba3..54fb50184a0 100644
--- a/src/server/authserver/Server/BattlenetPackets.h
+++ b/src/server/authserver/Server/BattlenetPackets.h
@@ -208,7 +208,7 @@ namespace Battlenet
public:
AuthComplete() : ServerPacket(PacketHeader(SMSG_AUTH_COMPLETE, AUTHENTICATION)),
Result(AUTH_OK), ErrorType(0), PingTimeout(120000), Threshold(25000000), Rate(1000),
- FirstName(""), LastName(""), Region(2), GameAccountId(0), GameAccountRegion(2), GameAccountName("")
+ FirstName(""), LastName(""), AccountId(0), Region(2), GameAccountRegion(2), GameAccountName("")
{
}
@@ -227,8 +227,8 @@ namespace Battlenet
uint32 Rate;
std::string FirstName;
std::string LastName;
+ uint32 AccountId;
uint8 Region;
- uint32 GameAccountId;
uint8 GameAccountRegion;
std::string GameAccountName;
uint64 GameAccountFlags;
diff --git a/src/server/authserver/Server/BattlenetSocket.cpp b/src/server/authserver/Server/BattlenetSocket.cpp
index 56744784167..eb8dc1158f0 100644
--- a/src/server/authserver/Server/BattlenetSocket.cpp
+++ b/src/server/authserver/Server/BattlenetSocket.cpp
@@ -59,7 +59,7 @@ Battlenet::Socket::ModuleHandler const Battlenet::Socket::ModuleHandlers[MODULE_
};
Battlenet::Socket::Socket(RealmSocket& socket) : _socket(socket), _accountId(0), _accountName(), _locale(),
- _os(), _build(0), _gameAccountId(0), _accountSecurityLevel(SEC_PLAYER), I(), s(), v(), b(), B(), K(),
+ _os(), _build(0), _gameAccountId(0), _gameAccountIndex(0), _accountSecurityLevel(SEC_PLAYER), I(), s(), v(), b(), B(), K(),
_reconnectProof(), _crypt(), _authed(false)
{
static uint8 const N_Bytes[] =
@@ -323,10 +323,12 @@ bool Battlenet::Socket::HandleAuthReconnect(PacketHeader& header, BitStream& pac
if (baseComponent != reconnect.Components.end())
_build = baseComponent->Build;
+ uint8 accountIndex = atol(reconnect.GameAccountName.substr(reconnect.GameAccountName.find_last_of('#') + 1).c_str());
+
Utf8ToUpperOnlyLatin(_accountName);
PreparedStatement* stmt = LoginDatabase.GetPreparedStatement(LOGIN_SEL_BNET_RECONNECT_INFO);
stmt->setString(0, _accountName);
- stmt->setString(1, reconnect.GameAccountName.c_str());
+ stmt->setUInt8(1, accountIndex);
PreparedQueryResult result = LoginDatabase.Query(stmt);
if (!result)
{
@@ -341,6 +343,7 @@ bool Battlenet::Socket::HandleAuthReconnect(PacketHeader& header, BitStream& pac
_accountId = fields[0].GetUInt32();
K.SetHexStr(fields[1].GetString().c_str());
_gameAccountId = fields[2].GetUInt32();
+ _gameAccountIndex = accountIndex;
ModuleInfo* thumbprint = sBattlenetMgr->CreateModule(_os, "Thumbprint");
ModuleInfo* resume = sBattlenetMgr->CreateModule(_os, "Resume");
@@ -768,8 +771,10 @@ bool Battlenet::Socket::HandlePasswordModule(BitStream* dataStream, ServerPacket
do
{
fields = result->Fetch();
+ std::ostringstream name;
+ name << "WoW" << uint32(fields[0].GetUInt8());
accounts.Write(2, 8);
- accounts.WriteString(fields[0].GetString(), 8);
+ accounts.WriteString(name.str(), 8);
} while (result->NextRow());
ModuleInfo* selectGameAccount = sBattlenetMgr->CreateModule(_os, "SelectGameAccount");
@@ -801,7 +806,8 @@ bool Battlenet::Socket::HandlePasswordModule(BitStream* dataStream, ServerPacket
return false;
}
- _gameAccountId = (*result)[1].GetUInt32();
+ _gameAccountId = fields[1].GetUInt32();
+ _gameAccountIndex = fields[0].GetUInt8();
request->Modules.push_back(sBattlenetMgr->CreateModule(_os, "RiskFingerprint"));
_modulesWaitingForData.push(MODULE_RISK_FINGERPRINT);
@@ -823,9 +829,18 @@ bool Battlenet::Socket::HandleSelectGameAccountModule(BitStream* dataStream, Ser
dataStream->Read<uint8>(8);
std::string account = dataStream->ReadString(8);
+ if (account.length() < 4)
+ {
+ AuthComplete* complete = new AuthComplete();
+ complete->SetAuthResult(LOGIN_NO_GAME_ACCOUNT);
+ ReplaceResponse(response, complete);
+ return false;
+ }
+
+ uint8 accountIndex = atol(account.substr(3).c_str());
PreparedStatement* stmt = LoginDatabase.GetPreparedStatement(LOGIN_SEL_BNET_GAME_ACCOUNT);
- stmt->setString(0, account);
+ stmt->setUInt8(0, accountIndex);
stmt->setUInt32(1, _accountId);
PreparedQueryResult result = LoginDatabase.Query(stmt);
if (!result)
@@ -856,6 +871,7 @@ bool Battlenet::Socket::HandleSelectGameAccountModule(BitStream* dataStream, Ser
}
_gameAccountId = fields[0].GetUInt32();
+ _gameAccountIndex = accountIndex;
ProofRequest* request = new ProofRequest();
request->Modules.push_back(sBattlenetMgr->CreateModule(_os, "RiskFingerprint"));
@@ -871,9 +887,9 @@ bool Battlenet::Socket::HandleRiskFingerprintModule(BitStream* dataStream, Serve
if (dataStream->Read<uint8>(8) == 1)
{
std::ostringstream str;
- str << _gameAccountId << "#1";
+ str << _accountId << "#" << uint32(_gameAccountIndex);
- complete->GameAccountId = _gameAccountId;
+ complete->AccountId = _accountId;
complete->GameAccountName = str.str();
complete->GameAccountFlags = GAMEACCOUNT_FLAG_PROPASS_LOCK;
diff --git a/src/server/authserver/Server/BattlenetSocket.h b/src/server/authserver/Server/BattlenetSocket.h
index c634a81b517..ee399e26b09 100644
--- a/src/server/authserver/Server/BattlenetSocket.h
+++ b/src/server/authserver/Server/BattlenetSocket.h
@@ -92,6 +92,7 @@ namespace Battlenet
std::string _os;
uint32 _build;
uint32 _gameAccountId;
+ uint8 _gameAccountIndex;
AccountTypes _accountSecurityLevel;
BigNumber N;