Codechange: add accessor for the packet type to Packet and make the internal state of Packet private

This commit is contained in:
Rubidium
2021-04-21 07:10:09 +02:00
committed by rubidium42
parent 3abefdf561
commit 450178d780
3 changed files with 13 additions and 3 deletions

View File

@@ -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<PacketType>(buffer[sizeof(PacketSize)]);
}
/**
* Read a boolean from the packet.
* @return The read data.