From 2c804dd34a58ff9702bd1ab2cab30f6a61503638 Mon Sep 17 00:00:00 2001 From: Mattes D Date: Mon, 9 Sep 2019 18:22:37 +0200 Subject: Protocol: Use logical outgoing packet types. --- src/Protocol/Packetizer.h | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) (limited to 'src/Protocol/Packetizer.h') diff --git a/src/Protocol/Packetizer.h b/src/Protocol/Packetizer.h index 6d2284976..e3a409cf0 100644 --- a/src/Protocol/Packetizer.h +++ b/src/Protocol/Packetizer.h @@ -30,13 +30,13 @@ class cPacketizer public: /** Starts serializing a new packet into the protocol's m_OutPacketBuffer. Locks the protocol's m_CSPacket to avoid multithreading issues. */ - cPacketizer(cProtocol & a_Protocol, UInt32 a_PacketType) : + cPacketizer(cProtocol & a_Protocol, cProtocol::ePacketType a_PacketType) : m_Protocol(a_Protocol), m_Out(a_Protocol.m_OutPacketBuffer), m_Lock(a_Protocol.m_CSPacket), m_PacketType(a_PacketType) // Used for logging purposes { - m_Out.WriteVarInt32(a_PacketType); + m_Out.WriteVarInt32(m_Protocol.GetPacketID(a_PacketType)); } /** Sends the packet via the contained protocol's SendPacket() function. */ @@ -140,7 +140,11 @@ public: /** Writes the specified UUID as a 128-bit BigEndian integer. */ void WriteUUID(const cUUID & a_UUID); - UInt32 GetPacketType(void) const { return m_PacketType; } + cProtocol::ePacketType GetPacketType() const { return m_PacketType; } + + /** Returns the human-readable representation of the packet type. + Used for logging the packets. */ + static AString PacketTypeToStr(cProtocol::ePacketType a_PacketType); protected: /** The protocol instance in which the packet is being constructed. */ @@ -154,7 +158,7 @@ protected: /** Type of the contained packet. Used for logging purposes, the packet type is encoded into m_Out immediately in constructor. */ - UInt32 m_PacketType; + cProtocol::ePacketType m_PacketType; } ; -- cgit v1.2.3