Skip to content

Commit 3450912

Browse files
committed
Core/Network: Move parsing of EarlyProcessClientPacket from WorldSocket::ReadDataHandlerResult to their handler functions
1 parent b384c2b commit 3450912

File tree

6 files changed

+177
-156
lines changed

6 files changed

+177
-156
lines changed

src/server/game/Server/Packets/AuthenticationPackets.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,11 @@ WorldPacket const* Pong::Write()
6060
return &_worldPacket;
6161
}
6262

63+
void LogDisconnect::Read()
64+
{
65+
_worldPacket >> Reason;
66+
}
67+
6368
WorldPacket const* AuthChallenge::Write()
6469
{
6570
_worldPacket.append(DosChallenge.data(), DosChallenge.size());

src/server/game/Server/Packets/AuthenticationPackets.h

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,18 @@ namespace WorldPackets
7373
uint32 Serial = 0;
7474
};
7575

76+
class LogDisconnect final : public EarlyProcessClientPacket<LogDisconnect>
77+
{
78+
public:
79+
explicit LogDisconnect(WorldPacket&& packet) : EarlyProcessClientPacket(CMSG_LOG_DISCONNECT, std::move(packet)) { }
80+
81+
uint32 Reason = 0;
82+
83+
private:
84+
friend EarlyProcessClientPacket;
85+
void Read() override;
86+
};
87+
7688
class AuthChallenge final : public ServerPacket
7789
{
7890
public:

src/server/game/Server/WorldSession.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -325,9 +325,9 @@ void WorldSession::AddInstanceConnection(WorldSession* session, std::weak_ptr<Wo
325325
}
326326

327327
/// Add an incoming packet to the queue
328-
void WorldSession::QueuePacket(WorldPacket* new_packet)
328+
void WorldSession::QueuePacket(WorldPacket&& new_packet)
329329
{
330-
_recvQueue.add(new_packet);
330+
_recvQueue.add(new WorldPacket(std::move(new_packet)));
331331
}
332332

333333
/// Logging helper for unexpected opcodes

src/server/game/Server/WorldSession.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1053,7 +1053,7 @@ class TC_GAME_API WorldSession
10531053
// May kick player on false depending on world config (handler should abort)
10541054
bool DisallowHyperlinksAndMaybeKick(std::string const& str);
10551055

1056-
void QueuePacket(WorldPacket* new_packet);
1056+
void QueuePacket(WorldPacket&& new_packet);
10571057
bool Update(uint32 diff, PacketFilter& updater);
10581058

10591059
/// Handle the authentication waiting queue (to be completed)

0 commit comments

Comments
 (0)