summaryrefslogtreecommitdiff
path: root/src/network/core/packet.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/network/core/packet.cpp')
-rw-r--r--src/network/core/packet.cpp12
1 files changed, 12 insertions, 0 deletions
diff --git a/src/network/core/packet.cpp b/src/network/core/packet.cpp
index c033aec98..e32b7fad8 100644
--- a/src/network/core/packet.cpp
+++ b/src/network/core/packet.cpp
@@ -231,6 +231,18 @@ bool Packet::HasPacketSizeData() const
}
/**
+ * Get the number of bytes in the packet.
+ * When sending a packet this is the size of the data up to that moment.
+ * When receiving a packet (before PrepareToRead) this is the allocated size for the data to be read.
+ * When reading a packet (after PrepareToRead) this is the full size of the packet.
+ * @return The packet's size.
+ */
+size_t Packet::Size() const
+{
+ return this->size;
+}
+
+/**
* Reads the packet size from the raw packet and stores it in the packet->size
* @return True iff the packet size seems plausible.
*/