summaryrefslogtreecommitdiffhomepage
path: root/NetEx/NetGram.h
diff options
context:
space:
mode:
Diffstat (limited to 'NetEx/NetGram.h')
-rw-r--r--NetEx/NetGram.h41
1 files changed, 19 insertions, 22 deletions
diff --git a/NetEx/NetGram.h b/NetEx/NetGram.h
index db2770f..d7a58c9 100644
--- a/NetEx/NetGram.h
+++ b/NetEx/NetGram.h
@@ -3,33 +3,31 @@
Copyright (c) 2011-2012, Starshatter OpenSource Distribution Contributors
Copyright (c) 1997-2006, Destroyer Studios LLC.
- AUTHOR: John DiCamillo
+ AUTHOR: John DiCamillo
- OVERVIEW
- ========
- Datagram (UDP) packet that implements the basic
- packet-oriented network protocol.
+ OVERVIEW
+ ========
+ Datagram (UDP) packet that implements the basic
+ packet-oriented network protocol.
*/
-
#ifndef NetGram_h
#define NetGram_h
-#include <windows.h>
+#include <cstdint>
+
#include "NetAddr.h"
#include "Text.h"
-// +-------------------------------------------------------------------+
-const int NET_GRAM_ACK = 0x80000000;
-const int NET_GRAM_RELIABLE = 0x40000000;
-const int NET_GRAM_SEQ_MASK = 0x3fffffff;
+const std::uint32_t NET_GRAM_ACK = 0x80000000;
+const std::uint32_t NET_GRAM_RELIABLE = 0x40000000;
+const std::uint32_t NET_GRAM_SEQ_MASK = 0x3fffffff;
-const int NET_GRAM_HEADER_SIZE = 4;
-const int NET_GRAM_MAX_SIZE = 1024;
+const std::uint32_t NET_GRAM_HEADER_SIZE = 4;
+const std::uint32_t NET_GRAM_MAX_SIZE = 1024;
-// +-------------------------------------------------------------------+
class NetGram
{
@@ -46,11 +44,11 @@ public:
addr == g.addr; }
int operator < (const NetGram& g) const { return Sequence() < g.Sequence(); }
- DWORD PacketID() const { return packet_id; }
- DWORD Sequence() const { return packet_id & NET_GRAM_SEQ_MASK; }
- DWORD SendTime() const { return send_time; }
- BYTE* Data() const { return (BYTE*) body.data(); }
- BYTE* UserData() const { return (BYTE*) body.data() + NET_GRAM_HEADER_SIZE; }
+ std::uint32_t PacketID() const { return packet_id; }
+ std::uint32_t Sequence() const { return packet_id & NET_GRAM_SEQ_MASK; }
+ std::uint32_t SendTime() const { return send_time; }
+ std::uint8_t* Data() const { return (std::uint8_t*) body.data(); }
+ std::uint8_t* UserData() const { return (std::uint8_t*) body.data() + NET_GRAM_HEADER_SIZE; }
int Size() const { return body.length(); }
const Text& Body() const { return body; }
const NetAddr& Address() const { return addr; }
@@ -68,9 +66,8 @@ protected:
NetAddr addr; // network address of remote host
int retries; // number of retries remaining (reliable packets only)
- DWORD send_time; // time in msec of most recent send attempt
-
- DWORD packet_id; // copy of packet id from header in body
+ std::uint32_t send_time; // time in msec of most recent send attempt
+ std::uint32_t packet_id; // copy of packet id from header in body
Text body; // header plus user data
};