summaryrefslogtreecommitdiff
path: root/src/network/core
diff options
context:
space:
mode:
Diffstat (limited to 'src/network/core')
-rw-r--r--src/network/core/packet.cpp10
-rw-r--r--src/network/core/packet.h4
2 files changed, 12 insertions, 2 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.
*/
diff --git a/src/network/core/packet.h b/src/network/core/packet.h
index d7ab7fee6..1a9c9faea 100644
--- a/src/network/core/packet.h
+++ b/src/network/core/packet.h
@@ -40,6 +40,7 @@ typedef uint8 PacketType; ///< Identifier for the packet
* (year % 4 == 0) and ((year % 100 != 0) or (year % 400 == 0))
*/
struct Packet {
+private:
/** The next packet. Used for queueing packets before sending. */
Packet *next;
/**
@@ -52,8 +53,6 @@ struct Packet {
PacketSize pos;
/** The buffer of this packet, of basically variable length up to SEND_MTU. */
byte *buffer;
-
-private:
/** Socket we're associated with. */
NetworkSocketHandler *cs;
@@ -82,6 +81,7 @@ public:
bool ParsePacketSize();
size_t Size() const;
void PrepareToRead();
+ PacketType GetPacketType() const;
bool CanReadFromPacket(size_t bytes_to_read, bool close_connection = false);
bool Recv_bool ();