From 450178d780eb885717c53a2dad62587332efc0f4 Mon Sep 17 00:00:00 2001 From: Rubidium Date: Wed, 21 Apr 2021 07:10:09 +0200 Subject: Codechange: add accessor for the packet type to Packet and make the internal state of Packet private --- src/network/core/packet.cpp | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'src/network/core/packet.cpp') diff --git a/src/network/core/packet.cpp b/src/network/core/packet.cpp index 9e9ce6901..d534df4d0 100644 --- a/src/network/core/packet.cpp +++ b/src/network/core/packet.cpp @@ -296,6 +296,16 @@ void Packet::PrepareToRead() this->pos = sizeof(PacketSize); } +/** + * Get the \c PacketType from this packet. + * @return The packet type. + */ +PacketType Packet::GetPacketType() const +{ + assert(this->Size() >= sizeof(PacketSize) + sizeof(PacketType)); + return static_cast(buffer[sizeof(PacketSize)]); +} + /** * Read a boolean from the packet. * @return The read data. -- cgit v1.2.3-70-g09d2