summaryrefslogtreecommitdiff
path: root/src/network/core/packet.cpp
diff options
context:
space:
mode:
authorRubidium <rubidium@openttd.org>2021-04-21 07:10:09 +0200
committerrubidium42 <rubidium42@users.noreply.github.com>2021-04-24 20:42:01 +0200
commit450178d780eb885717c53a2dad62587332efc0f4 (patch)
tree4536234455f40e6bd38060e198859790cef1c2fa /src/network/core/packet.cpp
parent3abefdf56190ef55d8680acb1aeab9f1b2fc8108 (diff)
downloadopenttd-450178d780eb885717c53a2dad62587332efc0f4.tar.xz
Codechange: add accessor for the packet type to Packet and make the internal state of Packet private
Diffstat (limited to 'src/network/core/packet.cpp')
-rw-r--r--src/network/core/packet.cpp10
1 files changed, 10 insertions, 0 deletions
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
@@ -297,6 +297,16 @@ void Packet::PrepareToRead()
}
/**
+ * 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.
*/