mirror of
https://github.com/mod-playerbots/azerothcore-wotlk.git
synced 2026-01-21 20:56:23 +00:00
Merge branch 'master' into Playerbot
# Conflicts: # src/server/game/Server/WorldSession.cpp # src/server/game/Server/WorldSession.h
This commit is contained in:
@@ -863,13 +863,6 @@ void WorldSession::SendAuthWaitQueue(uint32 position)
|
||||
}
|
||||
}
|
||||
|
||||
void WorldSession::LoadGlobalAccountData()
|
||||
{
|
||||
CharacterDatabasePreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_SEL_ACCOUNT_DATA);
|
||||
stmt->SetData(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)
|
||||
@@ -942,15 +935,17 @@ 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);
|
||||
|
||||
CharacterDatabasePreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_SEL_TUTORIALS);
|
||||
stmt->SetData(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].Get<uint32>();
|
||||
}
|
||||
}
|
||||
|
||||
m_TutorialsChanged = false;
|
||||
}
|
||||
@@ -1275,8 +1270,8 @@ void WorldSession::SendAddonsInfo()
|
||||
for (AddonMgr::BannedAddonList::const_iterator itr = bannedAddons->begin(); itr != bannedAddons->end(); ++itr)
|
||||
{
|
||||
data << uint32(itr->Id);
|
||||
data.append(itr->NameMD5, sizeof(itr->NameMD5));
|
||||
data.append(itr->VersionMD5, sizeof(itr->VersionMD5));
|
||||
data.append(itr->NameMD5);
|
||||
data.append(itr->VersionMD5);
|
||||
data << uint32(itr->Timestamp);
|
||||
data << uint32(1); // IsBanned
|
||||
}
|
||||
@@ -1649,6 +1644,75 @@ void WorldSession::SendTimeSync()
|
||||
_timeSyncNextCounter++;
|
||||
}
|
||||
|
||||
class AccountInfoQueryHolderPerRealm : public CharacterDatabaseQueryHolder
|
||||
{
|
||||
public:
|
||||
enum
|
||||
{
|
||||
GLOBAL_ACCOUNT_DATA = 0,
|
||||
TUTORIALS,
|
||||
|
||||
MAX_QUERIES
|
||||
};
|
||||
|
||||
AccountInfoQueryHolderPerRealm() { SetSize(MAX_QUERIES); }
|
||||
|
||||
bool Initialize(uint32 accountId)
|
||||
{
|
||||
bool ok = true;
|
||||
|
||||
CharacterDatabasePreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_SEL_ACCOUNT_DATA);
|
||||
stmt->SetData(0, accountId);
|
||||
ok = SetPreparedQuery(GLOBAL_ACCOUNT_DATA, stmt) && ok;
|
||||
|
||||
stmt = CharacterDatabase.GetPreparedStatement(CHAR_SEL_TUTORIALS);
|
||||
stmt->SetData(0, accountId);
|
||||
ok = SetPreparedQuery(TUTORIALS, stmt) && ok;
|
||||
|
||||
return ok;
|
||||
}
|
||||
};
|
||||
|
||||
void WorldSession::InitializeSession()
|
||||
{
|
||||
uint32 cacheVersion = sWorld->getIntConfig(CONFIG_CLIENTCACHE_VERSION);
|
||||
sScriptMgr->OnBeforeFinalizePlayerWorldSession(cacheVersion);
|
||||
|
||||
std::shared_ptr<AccountInfoQueryHolderPerRealm> realmHolder = std::make_shared<AccountInfoQueryHolderPerRealm>();
|
||||
if (!realmHolder->Initialize(GetAccountId()))
|
||||
{
|
||||
SendAuthResponse(AUTH_SYSTEM_ERROR, false);
|
||||
return;
|
||||
}
|
||||
|
||||
AddQueryHolderCallback(CharacterDatabase.DelayQueryHolder(realmHolder)).AfterComplete([this, cacheVersion](SQLQueryHolderBase const& holder)
|
||||
{
|
||||
InitializeSessionCallback(static_cast<AccountInfoQueryHolderPerRealm const&>(holder), cacheVersion);
|
||||
});
|
||||
}
|
||||
|
||||
void WorldSession::InitializeSessionCallback(CharacterDatabaseQueryHolder const& realmHolder, uint32 clientCacheVersion)
|
||||
{
|
||||
LoadAccountData(realmHolder.GetPreparedResult(AccountInfoQueryHolderPerRealm::GLOBAL_ACCOUNT_DATA), GLOBAL_CACHE_MASK);
|
||||
LoadTutorialsData(realmHolder.GetPreparedResult(AccountInfoQueryHolderPerRealm::TUTORIALS));
|
||||
|
||||
if (!m_inQueue)
|
||||
{
|
||||
SendAuthResponse(AUTH_OK, true);
|
||||
}
|
||||
else
|
||||
{
|
||||
SendAuthWaitQueue(0);
|
||||
}
|
||||
|
||||
SetInQueue(false);
|
||||
ResetTimeOutTime(false);
|
||||
|
||||
SendAddonsInfo();
|
||||
SendClientCacheVersion(clientCacheVersion);
|
||||
SendTutorialsData();
|
||||
}
|
||||
|
||||
LockedQueue<WorldPacket*>& WorldSession::GetPacketQueue()
|
||||
{
|
||||
return _recvQueue;
|
||||
|
||||
@@ -467,10 +467,9 @@ public:
|
||||
AccountData* GetAccountData(AccountDataType type) { return &m_accountData[type]; }
|
||||
void SetAccountData(AccountDataType type, time_t tm, std::string const& data);
|
||||
void SendAccountDataTimes(uint32 mask);
|
||||
void LoadGlobalAccountData();
|
||||
void LoadAccountData(PreparedQueryResult result, uint32 mask);
|
||||
|
||||
void LoadTutorialsData();
|
||||
void LoadTutorialsData(PreparedQueryResult result);
|
||||
void SendTutorialsData();
|
||||
void SaveTutorialsData(CharacterDatabaseTransaction trans);
|
||||
uint32 GetTutorialInt(uint8 index) const { return m_Tutorials[index]; }
|
||||
@@ -1100,6 +1099,9 @@ public: // opcodes handlers
|
||||
TransactionCallback& AddTransactionCallback(TransactionCallback&& callback);
|
||||
SQLQueryHolderCallback& AddQueryHolderCallback(SQLQueryHolderCallback&& callback);
|
||||
|
||||
void InitializeSession();
|
||||
void InitializeSessionCallback(CharacterDatabaseQueryHolder const& realmHolder, uint32 clientCacheVersion);
|
||||
|
||||
LockedQueue<WorldPacket*>& GetPacketQueue();
|
||||
|
||||
[[nodiscard]] bool IsBot() const
|
||||
|
||||
Reference in New Issue
Block a user