feat(core): allow to debug KickPlayer() (#1549)

This commit is contained in:
Francesco Borzì
2019-03-05 22:58:40 +01:00
committed by GitHub
parent e7ace60e59
commit 0758677578
19 changed files with 44 additions and 39 deletions
+1
View File
@@ -42,6 +42,7 @@ enum DebugLogFilters
LOG_FILTER_WARDEN = 0x00800000, // Warden related
LOG_FILTER_BATTLEFIELD = 0x01000000, // Battlefield related
LOG_FILTER_MODULES = 0x02000000, // Modules debug
LOG_FILTER_CLOSE_SOCKET = 0x04000000, // Whenever KickPlayer() or CloseSocket() are called
};
enum LogTypes
+1 -1
View File
@@ -70,7 +70,7 @@ namespace AccountMgr
if (Player* p = ObjectAccessor::FindPlayer(guid))
{
WorldSession* s = p->GetSession();
s->KickPlayer(); // mark session to remove at next session list update
s->KickPlayer("Delete account"); // mark session to remove at next session list update
s->LogoutPlayer(false); // logout player without waiting next session list update
}
+1 -1
View File
@@ -1737,7 +1737,7 @@ void Player::Update(uint32 p_time)
if (!IsPositionValid()) // pussywizard: will crash below at eg. GetZoneAndAreaId
{
sLog->outMisc("Player::Update - invalid position (%.1f, %.1f, %.1f)! Map: %u, MapId: %u, GUID: %u", GetPositionX(), GetPositionY(), GetPositionZ(), (FindMap() ? FindMap()->GetId() : 0), GetMapId(), GetGUIDLow());
GetSession()->KickPlayer();
GetSession()->KickPlayer("Invalid position");
return;
}
+1 -1
View File
@@ -3709,7 +3709,7 @@ void SafeUnitPointer::UnitDeleted()
if (ptr)
sLog->outMisc("SafeUnitPointer::UnitDeleted (A2)");
p->GetSession()->KickPlayer();
p->GetSession()->KickPlayer("Unit deleted");
}
}
else if (ptr)
@@ -758,7 +758,7 @@ void WorldSession::HandlePlayerLoginOpcode(WorldPacket & recvData)
if (PlayerLoading() || GetPlayer() != NULL)
{
sLog->outError("Player tries to login again, AccountId = %d", GetAccountId());
KickPlayer();
KickPlayer("Player tries to login again");
return;
}
@@ -768,7 +768,7 @@ void WorldSession::HandlePlayerLoginOpcode(WorldPacket & recvData)
if (!IsLegitCharacterForAccount(GUID_LOPART(playerGuid)))
{
sLog->outError("Account (%u) can't login with that character (%u).", GetAccountId(), GUID_LOPART(playerGuid));
KickPlayer();
KickPlayer("Account can't login with this character");
return;
}
@@ -794,7 +794,7 @@ void WorldSession::HandlePlayerLoginOpcode(WorldPacket & recvData)
}
if (p->GetGUID() != playerGuid)
sess->KickPlayer(); // no return, go to normal loading
sess->KickPlayer("No return, go to normal loading"); // no return, go to normal loading
else
{
// pussywizard: players stay ingame no matter what (prevent abuse), but allow to turn it off to stop crashing
@@ -883,7 +883,7 @@ void WorldSession::HandlePlayerLoginFromDB(LoginQueryHolder* holder)
if (!pCurrChar->LoadFromDB(GUID_LOPART(playerGuid), holder))
{
SetPlayer(NULL);
KickPlayer(); // disconnect client, player no set to session and it will not deleted or saved at kick
KickPlayer("HandlePlayerLoginFromDB"); // disconnect client, player no set to session and it will not deleted or saved at kick
delete pCurrChar; // delete it manually
delete holder; // delete all unprocessed queries
m_playerLoading = false;
@@ -1744,7 +1744,7 @@ void WorldSession::HandleCharCustomize(WorldPacket& recvData)
sLog->outError("Account %u, IP: %s tried to customise character %u, but it does not belong to their account!",
GetAccountId(), GetRemoteAddress().c_str(), GUID_LOPART(guid));
recvData.rfinish();
KickPlayer();
KickPlayer("HandleCharCustomize");
return;
}
@@ -2043,7 +2043,7 @@ void WorldSession::HandleCharFactionOrRaceChange(WorldPacket& recvData)
sLog->outError("Account %u, IP: %s tried to factionchange character %u, but it does not belong to their account!",
GetAccountId(), GetRemoteAddress().c_str(), GUID_LOPART(guid));
recvData.rfinish();
KickPlayer();
KickPlayer("HandleCharFactionOrRaceChange");
return;
}
+1 -1
View File
@@ -311,7 +311,7 @@ void WorldSession::HandleMessagechatOpcode(WorldPacket & recvData)
// GetPlayer()->GetGUIDLow(), msg.c_str());
if (sWorld->getIntConfig(CONFIG_CHAT_STRICT_LINK_CHECKING_KICK))
KickPlayer();
KickPlayer("CONFIG_CHAT_STRICT_LINK_CHECKING_KICK");
return;
}
+2 -2
View File
@@ -1699,7 +1699,7 @@ void WorldSession::HandleSetRaidDifficultyOpcode(WorldPacket & recv_data)
p->SetMap(homeMap0);
p->Relocate(0.0f, 0.0f, 0.0f, 0.0f);
if (!p->TeleportTo(571, 5790.20f, 2071.36f, 636.07f, 3.60f))
p->GetSession()->KickPlayer();
p->GetSession()->KickPlayer("HandleSetRaidDifficultyOpcode 1");
}
bool anyoneInside = false;
@@ -1736,7 +1736,7 @@ void WorldSession::HandleSetRaidDifficultyOpcode(WorldPacket & recv_data)
{
itr->first->SetRaidDifficulty(Difficulty(mode)); // needed for teleport not to fail
if (!itr->first->TeleportTo(*(foundMaps.begin()), itr->second.GetPositionX(), itr->second.GetPositionY(), itr->second.GetPositionZ(), itr->second.GetOrientation()))
itr->first->GetSession()->KickPlayer();
itr->first->GetSession()->KickPlayer("HandleSetRaidDifficultyOpcode 2");
}
}
}
+4 -4
View File
@@ -50,7 +50,7 @@ void WorldSession::HandleMoveWorldportAckOpcode()
// possible errors in the coordinate validity check
if (!MapManager::IsValidMapCoord(loc))
{
KickPlayer();
KickPlayer("!MapManager::IsValidMapCoord(loc)");
return;
}
@@ -119,7 +119,7 @@ void WorldSession::HandleMoveWorldportAckOpcode()
Cell cell(pair);
if (!GridCoord(cell.GridX(), cell.GridY()).IsCoordValid())
{
KickPlayer();
KickPlayer("!GridCoord(cell.GridX(), cell.GridY()).IsCoordValid()");
return;
}
newMap->LoadGrid(GetPlayer()->GetPositionX(), GetPlayer()->GetPositionY());
@@ -167,7 +167,7 @@ void WorldSession::HandleMoveWorldportAckOpcode()
Cell cell2(pair2);
if (!GridCoord(cell2.GridX(), cell2.GridY()).IsCoordValid())
{
KickPlayer();
KickPlayer("!GridCoord(cell2.GridX(), cell2.GridY()).IsCoordValid()");
return;
}
newMap->LoadGrid(GetPlayer()->GetPositionX(), GetPlayer()->GetPositionY());
@@ -577,7 +577,7 @@ void WorldSession::HandleForceSpeedChangeAck(WorldPacket &recvData)
{
sLog->outBasic("Player %s from account id %u kicked for incorrect speed (must be %f instead %f)",
_player->GetName().c_str(), GetAccountId(), _player->GetSpeed(move_type), newspeed);
KickPlayer();
KickPlayer("Incorrect speed");
}
}
}
+5 -5
View File
@@ -144,7 +144,7 @@ WorldSession::~WorldSession()
/// - If have unclosed socket, close it
if (m_Socket)
{
m_Socket->CloseSocket();
m_Socket->CloseSocket("WorldSession destructor");
m_Socket->RemoveReference();
m_Socket = NULL;
}
@@ -236,7 +236,7 @@ void WorldSession::SendPacket(WorldPacket const* packet)
#endif
if (m_Socket->SendPacket(*packet) == -1)
m_Socket->CloseSocket();
m_Socket->CloseSocket("m_Socket->SendPacket(*packet) == -1");
}
/// Add an incoming packet to the queue
@@ -255,7 +255,7 @@ bool WorldSession::Update(uint32 diff, PacketFilter& updater)
/// If necessary, kick the player because the client didn't send anything for too long
/// (or they've been idling in character select)
if (sWorld->getBoolConfig(CONFIG_CLOSE_IDLE_CONNECTIONS) && IsConnectionIdle())
m_Socket->CloseSocket();
m_Socket->CloseSocket("Client didn't send anything for too long");
}
HandleTeleportTimeout(updater.ProcessLogout());
@@ -611,10 +611,10 @@ void WorldSession::LogoutPlayer(bool save)
}
/// Kick a player out of the World
void WorldSession::KickPlayer(bool setKicked)
void WorldSession::KickPlayer(std::string const& reason, bool setKicked)
{
if (m_Socket)
m_Socket->CloseSocket();
m_Socket->CloseSocket(reason);
if (setKicked)
SetKicked(true); // pussywizard: the session won't be left ingame for 60 seconds and to also kick offline session
+1 -1
View File
@@ -247,7 +247,7 @@ class WorldSession
}
void LogoutPlayer(bool save);
void KickPlayer(bool setKicked = true);
void KickPlayer(std::string const& reason, bool setKicked = true);
void QueuePacket(WorldPacket* new_packet);
bool Update(uint32 diff, PacketFilter& updater);
+4 -1
View File
@@ -119,8 +119,11 @@ bool WorldSocket::IsClosed(void) const
return closing_;
}
void WorldSocket::CloseSocket(void)
void WorldSocket::CloseSocket(std::string const& reason)
{
if (!reason.empty())
sLog->outDebug(LOG_FILTER_CLOSE_SOCKET, "Socket closed because of: %s", reason.c_str());
{
ACE_GUARD (LockType, Guard, m_OutBufferLock);
+1 -1
View File
@@ -88,7 +88,7 @@ class WorldSocket : public WorldHandler
bool IsClosed (void) const;
/// Close the socket.
void CloseSocket (void);
void CloseSocket(std::string const& reason);
/// Get address of connected peer.
const std::string& GetRemoteAddress (void) const;
+1 -1
View File
@@ -169,7 +169,7 @@ class ReactorRunnable : protected ACE_Task_Base
t = i;
++i;
(*t)->CloseSocket();
(*t)->CloseSocket("svc()");
sScriptMgr->OnSocketClose((*t), false);
+2 -2
View File
@@ -98,7 +98,7 @@ void Warden::Update()
if (maxClientResponseDelay > 0)
{
if (_clientResponseTimer > maxClientResponseDelay * IN_MILLISECONDS)
_session->KickPlayer();
_session->KickPlayer("clientResponseTimer > maxClientResponseDelay");
else
_clientResponseTimer += diff;
}
@@ -218,7 +218,7 @@ std::string Warden::Penalty(WardenCheck* check /*= NULL*/, uint16 checkFailed /*
return "None";
break;
case WARDEN_ACTION_KICK:
_session->KickPlayer();
_session->KickPlayer("WARDEN_ACTION_KICK");
return "Kick";
break;
case WARDEN_ACTION_BAN:
+1 -1
View File
@@ -278,5 +278,5 @@ void WardenMac::HandleData(ByteBuffer &buff)
//found = true;
}
_session->KickPlayer();
_session->KickPlayer("WardenMac");
}
+9 -9
View File
@@ -231,7 +231,7 @@ bool World::KickSession(uint32 id)
if (itr->second->PlayerLoading())
return false;
itr->second->KickPlayer(false);
itr->second->KickPlayer("KickSession", false);
}
return true;
@@ -248,9 +248,9 @@ void World::AddSession_(WorldSession* s)
// kick existing session with same account (if any)
// if character on old session is being loaded, then return
if (!KickSession (s->GetAccountId()))
if (!KickSession(s->GetAccountId()))
{
s->KickPlayer();
s->KickPlayer("kick existing session with same account");
delete s; // session not added yet in session list, so not listed in queue
return;
}
@@ -2418,11 +2418,11 @@ void World::KickAll()
// session not removed at kick and will removed in next update tick
for (SessionMap::const_iterator itr = m_sessions.begin(); itr != m_sessions.end(); ++itr)
itr->second->KickPlayer();
itr->second->KickPlayer("KickAll sessions");
// pussywizard: kick offline sessions
for (SessionMap::const_iterator itr = m_offlineSessions.begin(); itr != m_offlineSessions.end(); ++itr)
itr->second->KickPlayer();
itr->second->KickPlayer("KickAll offline sessions");
}
/// Kick (and save) all players with security level less `sec`
@@ -2431,7 +2431,7 @@ void World::KickAllLess(AccountTypes sec)
// session not removed at kick and will removed in next update tick
for (SessionMap::const_iterator itr = m_sessions.begin(); itr != m_sessions.end(); ++itr)
if (itr->second->GetSecurity() < sec)
itr->second->KickPlayer();
itr->second->KickPlayer("KickAllLess");
}
/// Ban an account or ban an IP address, duration will be parsed using TimeStringToSecs if it is positive, otherwise permban
@@ -2511,10 +2511,10 @@ BanReturn World::BanAccount(BanMode mode, std::string const& nameOrIP, std::stri
if (WorldSession* sess = FindSession(account))
if (sess->GetPlayerName() != author)
sess->KickPlayer();
sess->KickPlayer("FindSession(account)->GetPlayerName() != author");
if (WorldSession* sess = FindOfflineSession(account))
if (sess->GetPlayerName() != author)
sess->KickPlayer();
sess->KickPlayer("FindOfflineSession(account)->GetPlayerName() != author");
} while (resultAccounts->NextRow());
LoginDatabase.CommitTransaction(trans);
@@ -2582,7 +2582,7 @@ BanReturn World::BanCharacter(std::string const& name, std::string const& durati
CharacterDatabase.Execute(stmt);
if (pBanned)
pBanned->GetSession()->KickPlayer();
pBanned->GetSession()->KickPlayer("Ban");
return BAN_SUCCESS;
}
+1 -1
View File
@@ -687,7 +687,7 @@ public:
{
characterGuid = player->GetGUID();
accountId = player->GetSession()->GetAccountId();
player->GetSession()->KickPlayer();
player->GetSession()->KickPlayer("HandleCharacterEraseCommand");
}
else
{
+1 -1
View File
@@ -1134,7 +1134,7 @@ public:
else
handler->PSendSysMessage(LANG_COMMAND_KICKMESSAGE, playerName.c_str());
target->GetSession()->KickPlayer();
target->GetSession()->KickPlayer("HandleKickPlayerCommand");
return true;
}
@@ -500,6 +500,7 @@ LogFileLevel = 0
# 2097152 - Anything related to guilds
# 4194304 - Anything related to transports
# 8388608 - Anything related to Warden anti cheat
# 67108864 - Whenever KickPlayer() or CloseSocket() are called
#
# Simply add the values together to create a bitmask.
# For more info see enum DebugLogFilters in Log.h