Skip to content

Commit

Permalink
Only init warden after session is added to world.
Browse files Browse the repository at this point in the history
  • Loading branch information
ratkosrb committed Aug 31, 2023
1 parent 8e35ae2 commit f137320
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/game/Protocol/WorldSocket.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -314,9 +314,9 @@ int WorldSocket::HandleAuthSession(WorldPacket& recvPacket)
m_Session->SetAccountFlags(accFlags);
m_Session->SetOS(clientOs);
m_Session->SetPlatform(clientPlatform);
m_Session->SetSessionKey(K);
m_Session->LoadGlobalAccountData();
m_Session->LoadTutorialsData();
m_Session->InitWarden(&K);

// In case needed sometime the second arg is in microseconds 1 000 000 = 1 sec
ACE_OS::sleep(ACE_Time_Value(0, 10000));
Expand Down
5 changes: 5 additions & 0 deletions src/game/World.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -315,6 +315,9 @@ void World::AddSession_(WorldSession* s)

UpdateMaxSessionCounters();

// Only init warden after session has been added
s->InitWarden();

// Updates the population
if (playerLimit > 0)
{
Expand Down Expand Up @@ -400,6 +403,7 @@ bool World::RemoveQueuedSession(WorldSession* sess)
pop_sess->SetInQueue(false);
pop_sess->m_idleTime = WorldTimer::getMSTime();
pop_sess->SendAuthWaitQue(0);
pop_sess->InitWarden();
m_QueuedSessions.pop_front();

// update iter to point first queued socket or end() if queue is empty now
Expand Down Expand Up @@ -2683,6 +2687,7 @@ void World::UpdateSessions(uint32 diff)
pop_sess->SetInQueue(false);
pop_sess->m_idleTime = WorldTimer::getMSTime();
pop_sess->SendAuthWaitQue(0);
pop_sess->InitWarden();
m_QueuedSessions.pop_front();
}

Expand Down
5 changes: 3 additions & 2 deletions src/game/WorldSession.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1088,9 +1088,10 @@ void WorldSession::ExecuteOpcode(OpcodeHandler const& opHandle, WorldPacket* pac
LogUnprocessedTail(packet);
}

void WorldSession::InitWarden(BigNumber* k)
void WorldSession::InitWarden()
{
m_warden = sAnticheatMgr->CreateWardenFor(this, k);
MANGOS_ASSERT(!m_warden);
m_warden = sAnticheatMgr->CreateWardenFor(this, &m_sessionKey);
}

void WorldSession::InitCheatData(Player* pPlayer)
Expand Down
5 changes: 4 additions & 1 deletion src/game/WorldSession.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
#include "Chat/AbstractPlayer.h"
#include "SniffFile.h"
#include "ClientDefines.h"
#include "Auth/BigNumber.h"

struct ItemPrototype;
struct AuctionEntry;
Expand Down Expand Up @@ -374,7 +375,8 @@ class WorldSession
void SetBot(std::shared_ptr<PlayerBotEntry> const& b) { m_bot = b; }

// Warden / Anticheat
void InitWarden(BigNumber* K);
void InitWarden();
void SetSessionKey(BigNumber const& sessionKey) { m_sessionKey = sessionKey; }
Warden* GetWarden() const { return m_warden; }
void InitCheatData(Player* pPlayer);
MovementAnticheat* GetCheatData();
Expand Down Expand Up @@ -909,6 +911,7 @@ class WorldSession
uint32 m_exhaustionState;
uint32 m_charactersCount;
uint32 m_characterMaxLevel;
BigNumber m_sessionKey;
AccountData m_accountData[NUM_ACCOUNT_DATA_TYPES];
uint32 m_tutorials[ACCOUNT_TUTORIALS_COUNT];
TutorialDataState m_tutorialState;
Expand Down

0 comments on commit f137320

Please sign in to comment.