summaryrefslogtreecommitdiff
path: root/src/network/core/packet.h
diff options
context:
space:
mode:
authorRubidium <rubidium@openttd.org>2021-04-18 14:42:06 +0200
committerrubidium42 <rubidium42@users.noreply.github.com>2021-04-25 21:27:54 +0200
commit8b302761d4ca51f41eaff4097c9afa4f3aec5ec5 (patch)
treeca13d813a2793b5f1d562ce4e9434138aceb523c /src/network/core/packet.h
parent97288bc286bf4b4b92cf29bcd051c49b2299624b (diff)
downloadopenttd-8b302761d4ca51f41eaff4097c9afa4f3aec5ec5.tar.xz
Codechange: allow different limits in packet sizes
Diffstat (limited to 'src/network/core/packet.h')
-rw-r--r--src/network/core/packet.h15
1 files changed, 9 insertions, 6 deletions
diff --git a/src/network/core/packet.h b/src/network/core/packet.h
index 1ac7f18a1..db051005c 100644
--- a/src/network/core/packet.h
+++ b/src/network/core/packet.h
@@ -25,10 +25,11 @@ typedef uint8 PacketType; ///< Identifier for the packet
* Internal entity of a packet. As everything is sent as a packet,
* all network communication will need to call the functions that
* populate the packet.
- * Every packet can be at most SEND_MTU bytes. Overflowing this
- * limit will give an assertion when sending (i.e. writing) the
- * packet. Reading past the size of the packet when receiving
- * will return all 0 values and "" in case of the string.
+ * Every packet can be at most a limited number bytes set in the
+ * constructor. Overflowing this limit will give an assertion when
+ * sending (i.e. writing) the packet. Reading past the size of the
+ * packet when receiving will return all 0 values and "" in case of
+ * the string.
*
* --- Points of attention ---
* - all > 1 byte integral values are written in little endian,
@@ -47,13 +48,15 @@ private:
PacketSize pos;
/** The buffer of this packet. */
std::vector<byte> buffer;
+ /** The limit for the packet size. */
+ size_t limit;
/** Socket we're associated with. */
NetworkSocketHandler *cs;
public:
- Packet(NetworkSocketHandler *cs, size_t initial_read_size = sizeof(PacketSize));
- Packet(PacketType type);
+ Packet(NetworkSocketHandler *cs, size_t limit, size_t initial_read_size = sizeof(PacketSize));
+ Packet(PacketType type, size_t limit = SEND_MTU);
static void AddToQueue(Packet **queue, Packet *packet);
static Packet *PopFromQueue(Packet **queue);