Merge pull request #370 from pjerra/core/kick-requested-getter

WorldSession: add IsKickRequested() for sessionless bot sessions
This commit is contained in:
Karrz1
2026-11-20 07:28:35 +00:00
committed by GitHub
2 changed files with 6 additions and 4 deletions
+3 -3
View File
@@ -604,7 +604,7 @@ bool WorldSession::Update(uint32 diff, PacketFilter& updater)
if (std::ranges::any_of(m_Socket, [](std::shared_ptr<WorldSocket> const& s) { return s && !s->IsOpen(); }))
{
expireTime -= expireTime > diff ? diff : expireTime;
if (expireTime < diff || forceExit || !GetPlayer())
if (expireTime < diff || forceExit.load(std::memory_order_relaxed) || !GetPlayer())
{
for (std::shared_ptr<WorldSocket>& socket : m_Socket)
{
@@ -804,14 +804,14 @@ void WorldSession::KickPlayer(std::string_view reason)
// A headless bot session has no socket to close; flag the exit directly so BotSession::Update
// logs the bot out and the session manager reaps it (failed logins, GM kick/ban).
if (IsBot())
forceExit = true;
forceExit.store(true, std::memory_order_relaxed);
for (std::shared_ptr<WorldSocket> const& socket : m_Socket)
{
if (socket)
{
socket->CloseSocket();
forceExit = true;
forceExit.store(true, std::memory_order_relaxed);
}
}
}
+3 -1
View File
@@ -1100,6 +1100,8 @@ class TC_GAME_API WorldSession
void LogoutPlayer(bool save);
void KickPlayer(std::string_view reason);
// True once a kick was requested; a headless bot session has no socket to observe the close.
bool IsKickRequested() const { return forceExit.load(std::memory_order_relaxed); }
// Returns true if all contained hyperlinks are valid
// May kick player on false depending on world config (handler should abort)
bool ValidateHyperlinksAndMaybeKick(std::string const& str);
@@ -2138,7 +2140,7 @@ class TC_GAME_API WorldSession
LockedQueue<WorldPacket*> _recvQueue;
rbac::RBACData* _RBACData;
uint32 expireTime;
bool forceExit;
std::atomic<bool> forceExit;
bool _motdPending = false; // MOTD due once the client's loading screen after the login is gone
std::unique_ptr<boost::circular_buffer<std::pair<int64, uint32>>> _timeSyncClockDeltaQueue; // first member: clockDelta. Second member: latency of the packet exchange that was used to compute that clockDelta.