Core/PacketIO: Stop WorldSession packet processing loop immediately when AntiDOS kicks/bans the player

# Conflicts:
#	src/server/game/Server/WorldSession.cpp
This commit is contained in:
Shauren authored and Ovahlord committed 2022-04-17 01:28:59 +02:00
1 parent 62368ec93e
commit 76fc64b038
1 file changed
+10 -1
+10 -1
View File
@@ -355,6 +355,8 @@ bool WorldSession::Update(uint32 diff, PacketFilter& updater)
uint32 processedPackets = 0;
time_t currentTime = GameTime::GetGameTime();
constexpr uint32 MAX_PROCESSED_PACKETS_IN_SAME_WORLDSESSION_UPDATE = 100;
while (m_Socket[CONNECTION_TYPE_REALM] && _recvQueue.next(packet, updater))
{
ClientOpcodeHandler const* opHandle = opcodeTable[static_cast<OpcodeClient>(packet->GetOpcode())];
@@ -381,6 +383,8 @@ bool WorldSession::Update(uint32 diff, PacketFilter& updater)
sScriptMgr->OnPacketReceive(this, *packet);
opHandle->Call(this, *packet);
}
else
processedPackets = MAX_PROCESSED_PACKETS_IN_SAME_WORLDSESSION_UPDATE; // break out of packet processing loop
// lag can cause STATUS_LOGGEDIN opcodes to arrive after the player started a transfer
break;
case STATUS_LOGGEDIN_OR_RECENTLY_LOGGOUT:
@@ -393,6 +397,8 @@ bool WorldSession::Update(uint32 diff, PacketFilter& updater)
sScriptMgr->OnPacketReceive(this, *packet);
opHandle->Call(this, *packet);
}
else
processedPackets = MAX_PROCESSED_PACKETS_IN_SAME_WORLDSESSION_UPDATE; // break out of packet processing loop
break;
case STATUS_TRANSFER:
if (!_player)
@@ -404,6 +410,8 @@ bool WorldSession::Update(uint32 diff, PacketFilter& updater)
sScriptMgr->OnPacketReceive(this, *packet);
opHandle->Call(this, *packet);
}
else
processedPackets = MAX_PROCESSED_PACKETS_IN_SAME_WORLDSESSION_UPDATE; // break out of packet processing loop
break;
case STATUS_AUTHED:
// prevent cheating with skip queue wait
@@ -423,6 +431,8 @@ bool WorldSession::Update(uint32 diff, PacketFilter& updater)
sScriptMgr->OnPacketReceive(this, *packet);
opHandle->Call(this, *packet);
}
else
processedPackets = MAX_PROCESSED_PACKETS_IN_SAME_WORLDSESSION_UPDATE; // break out of packet processing loop
break;
case STATUS_NEVER:
TC_LOG_ERROR("network.opcode", "Received not allowed opcode %s from %s", GetOpcodeNameForLogging(static_cast<OpcodeClient>(packet->GetOpcode())).c_str()
@@ -451,7 +461,6 @@ bool WorldSession::Update(uint32 diff, PacketFilter& updater)
deletePacket = true;
#define MAX_PROCESSED_PACKETS_IN_SAME_WORLDSESSION_UPDATE 100
processedPackets++;
//process only a max amout of packets in 1 Update() call.