Make login process async, hand cherry-picked
This commit is contained in:
1 parent
e9a56cf409
commit
931eaff000
18 files changed
+711
-385
No files matched your search
@@ -99,7 +99,7 @@ bool WorldSessionFilter::Process(WorldPacket* packet)
|
||||
}
|
||||
|
||||
/// WorldSession constructor
|
||||
WorldSession::WorldSession(uint32 id, uint32 battlenetAccountId, std::shared_ptr<WorldSocket> sock, AccountTypes sec, uint8 expansion, time_t mute_time, LocaleConstant locale, uint32 recruiter, bool isARecruiter):
|
||||
WorldSession::WorldSession(uint32 id, std::string&& name, uint32 battlenetAccountId, std::shared_ptr<WorldSocket> sock, AccountTypes sec, uint8 expansion, time_t mute_time, LocaleConstant locale, uint32 recruiter, bool isARecruiter) :
|
||||
m_muteTime(mute_time),
|
||||
m_timeOutTime(0),
|
||||
AntiDOS(this),
|
||||
@@ -108,6 +108,7 @@ WorldSession::WorldSession(uint32 id, uint32 battlenetAccountId, std::shared_ptr
|
||||
m_Socket(sock),
|
||||
_security(sec),
|
||||
_accountId(id),
|
||||
_accountName(std::move(name)),
|
||||
_battlenetAccountId(battlenetAccountId),
|
||||
m_expansion(expansion),
|
||||
_warden(NULL),
|
||||
@@ -192,11 +193,11 @@ std::string WorldSession::GetPlayerInfo() const
|
||||
{
|
||||
std::ostringstream ss;
|
||||
|
||||
ss << "[Player: " << GetPlayerName() << " (";
|
||||
if (_player != NULL)
|
||||
ss << _player->GetGUID().ToString() << ", ";
|
||||
ss << "[Player: ";
|
||||
if (!m_playerLoading && _player)
|
||||
ss << _player->GetName() << ' ' << _player->GetGUID().ToString() << ", ";
|
||||
|
||||
ss << "Account: " << GetAccountId() << ")]";
|
||||
ss << "Account: " << GetAccountId() << "]";
|
||||
|
||||
return ss.str();
|
||||
}
|
||||
@@ -724,13 +725,6 @@ void WorldSession::SendAuthWaitQue(uint32 position)
|
||||
}
|
||||
}
|
||||
|
||||
void WorldSession::LoadGlobalAccountData()
|
||||
{
|
||||
PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_SEL_ACCOUNT_DATA);
|
||||
stmt->setUInt32(0, GetAccountId());
|
||||
LoadAccountData(CharacterDatabase.Query(stmt), GLOBAL_CACHE_MASK);
|
||||
}
|
||||
|
||||
void WorldSession::LoadAccountData(PreparedQueryResult result, uint32 mask)
|
||||
{
|
||||
for (uint32 i = 0; i < NUM_ACCOUNT_DATA_TYPES; ++i)
|
||||
@@ -806,13 +800,11 @@ void WorldSession::SendAccountDataTimes(uint32 mask)
|
||||
SendPacket(&data);
|
||||
}
|
||||
|
||||
void WorldSession::LoadTutorialsData()
|
||||
void WorldSession::LoadTutorialsData(PreparedQueryResult result)
|
||||
{
|
||||
memset(m_Tutorials, 0, sizeof(uint32) * MAX_ACCOUNT_TUTORIAL_VALUES);
|
||||
|
||||
PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_SEL_TUTORIALS);
|
||||
stmt->setUInt32(0, GetAccountId());
|
||||
if (PreparedQueryResult result = CharacterDatabase.Query(stmt))
|
||||
if (result)
|
||||
for (uint8 i = 0; i < MAX_ACCOUNT_TUTORIAL_VALUES; ++i)
|
||||
m_Tutorials[i] = (*result)[i].GetUInt32();
|
||||
|
||||
@@ -845,7 +837,7 @@ void WorldSession::SaveTutorialsData(SQLTransaction &trans)
|
||||
m_TutorialsChanged = false;
|
||||
}
|
||||
|
||||
void WorldSession::ReadAddonsInfo(WorldPacket &data)
|
||||
void WorldSession::ReadAddonsInfo(ByteBuffer &data)
|
||||
{
|
||||
if (data.rpos() + 4 > data.size())
|
||||
return;
|
||||
@@ -1055,6 +1047,10 @@ void WorldSession::ProcessQueryCallbacks()
|
||||
{
|
||||
PreparedQueryResult result;
|
||||
|
||||
if (_realmAccountLoginCallback.valid() && _realmAccountLoginCallback.wait_for(std::chrono::seconds(0)) == std::future_status::ready &&
|
||||
_accountLoginCallback.valid() && _accountLoginCallback.wait_for(std::chrono::seconds(0)) == std::future_status::ready)
|
||||
InitializeSessionCallback(_realmAccountLoginCallback.get(), _accountLoginCallback.get());
|
||||
|
||||
//! HandleCharEnumOpcode
|
||||
if (_charEnumCallback.valid() && _charEnumCallback.wait_for(std::chrono::seconds(0)) == std::future_status::ready)
|
||||
{
|
||||
@@ -1154,15 +1150,115 @@ void WorldSession::InitWarden(BigNumber* k, std::string const& os)
|
||||
void WorldSession::LoadPermissions()
|
||||
{
|
||||
uint32 id = GetAccountId();
|
||||
std::string name;
|
||||
AccountMgr::GetName(id, name);
|
||||
uint8 secLevel = GetSecurity();
|
||||
|
||||
_RBACData = new rbac::RBACData(id, name, realmHandle.Index, secLevel);
|
||||
_RBACData->LoadFromDB();
|
||||
|
||||
TC_LOG_DEBUG("rbac", "WorldSession::LoadPermissions [AccountId: %u, Name: %s, realmId: %d, secLevel: %u]",
|
||||
id, name.c_str(), realmHandle.Index, secLevel);
|
||||
id, _accountName.c_str(), realmHandle.Index, secLevel);
|
||||
|
||||
_RBACData = new rbac::RBACData(id, _accountName, realmHandle.Index, secLevel);
|
||||
_RBACData->LoadFromDB();
|
||||
}
|
||||
|
||||
PreparedQueryResultFuture WorldSession::LoadPermissionsAsync()
|
||||
{
|
||||
uint32 id = GetAccountId();
|
||||
uint8 secLevel = GetSecurity();
|
||||
TC_LOG_DEBUG("rbac", "WorldSession::LoadPermissions [AccountId: %u, Name: %s, realmId: %d, secLevel: %u]",
|
||||
id, _accountName.c_str(), realmHandle.Index, secLevel);
|
||||
|
||||
_RBACData = new rbac::RBACData(id, _accountName, realmHandle.Index, secLevel);
|
||||
return _RBACData->LoadFromDBAsync();
|
||||
}
|
||||
|
||||
class AccountInfoQueryHolderPerRealm : public SQLQueryHolder
|
||||
{
|
||||
public:
|
||||
enum
|
||||
{
|
||||
GLOBAL_ACCOUNT_DATA = 0,
|
||||
TUTORIALS,
|
||||
|
||||
MAX_QUERIES
|
||||
};
|
||||
|
||||
AccountInfoQueryHolderPerRealm() { SetSize(MAX_QUERIES); }
|
||||
|
||||
bool Initialize(uint32 accountId, uint32 /*battlenetAccountId*/)
|
||||
{
|
||||
bool ok = true;
|
||||
|
||||
PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_SEL_ACCOUNT_DATA);
|
||||
stmt->setUInt32(0, accountId);
|
||||
ok = SetPreparedQuery(GLOBAL_ACCOUNT_DATA, stmt) && ok;
|
||||
|
||||
stmt = CharacterDatabase.GetPreparedStatement(CHAR_SEL_TUTORIALS);
|
||||
stmt->setUInt32(0, accountId);
|
||||
ok = SetPreparedQuery(TUTORIALS, stmt) && ok;
|
||||
|
||||
return ok;
|
||||
}
|
||||
};
|
||||
|
||||
class AccountInfoQueryHolder : public SQLQueryHolder
|
||||
{
|
||||
public:
|
||||
enum
|
||||
{
|
||||
MAX_QUERIES
|
||||
};
|
||||
|
||||
AccountInfoQueryHolder() { SetSize(MAX_QUERIES); }
|
||||
|
||||
bool Initialize(uint32 /*accountId*/, uint32 /*battlenetAccountId*/)
|
||||
{
|
||||
bool ok = true;
|
||||
|
||||
return ok;
|
||||
}
|
||||
};
|
||||
|
||||
void WorldSession::InitializeSession()
|
||||
{
|
||||
AccountInfoQueryHolderPerRealm* realmHolder = new AccountInfoQueryHolderPerRealm();
|
||||
if (!realmHolder->Initialize(GetAccountId(), GetBattlenetAccountId()))
|
||||
{
|
||||
delete realmHolder;
|
||||
SendAuthResponse(AUTH_SYSTEM_ERROR, false);
|
||||
return;
|
||||
}
|
||||
|
||||
AccountInfoQueryHolder* holder = new AccountInfoQueryHolder();
|
||||
if (!holder->Initialize(GetAccountId(), GetBattlenetAccountId()))
|
||||
{
|
||||
delete realmHolder;
|
||||
delete holder;
|
||||
SendAuthResponse(AUTH_SYSTEM_ERROR, false);
|
||||
return;
|
||||
}
|
||||
|
||||
_realmAccountLoginCallback = CharacterDatabase.DelayQueryHolder(realmHolder);
|
||||
_accountLoginCallback = LoginDatabase.DelayQueryHolder(holder);
|
||||
}
|
||||
|
||||
void WorldSession::InitializeSessionCallback(SQLQueryHolder* realmHolder, SQLQueryHolder* holder)
|
||||
{
|
||||
LoadAccountData(realmHolder->GetPreparedResult(AccountInfoQueryHolderPerRealm::GLOBAL_ACCOUNT_DATA), GLOBAL_CACHE_MASK);
|
||||
LoadTutorialsData(realmHolder->GetPreparedResult(AccountInfoQueryHolderPerRealm::TUTORIALS));
|
||||
|
||||
if (!m_inQueue)
|
||||
SendAuthResponse(AUTH_OK, false);
|
||||
else
|
||||
SendAuthWaitQue(0);
|
||||
|
||||
SetInQueue(false);
|
||||
ResetTimeOutTime();
|
||||
|
||||
SendAddonsInfo();
|
||||
SendClientCacheVersion(sWorld->getIntConfig(CONFIG_CLIENTCACHE_VERSION));
|
||||
SendTutorialsData();
|
||||
|
||||
delete realmHolder;
|
||||
delete holder;
|
||||
}
|
||||
|
||||
rbac::RBACData* WorldSession::GetRBACData()
|
||||
|
||||
Reference in new issue
Block a user