summaryrefslogtreecommitdiffhomepage
path: root/NetEx/NetMsg.h
diff options
context:
space:
mode:
authorAki <please@ignore.pl>2022-03-30 23:50:47 +0200
committerAki <please@ignore.pl>2022-03-30 23:50:47 +0200
commita7bba97ddbb49f626951c4cb7fb72a9ba879f64c (patch)
tree3b04694b3ac9e0a05a422499d99146d47499d5ae /NetEx/NetMsg.h
parentacecd34e8ffe8c77a6e7fb4f0fa9b8375a0d176a (diff)
downloadstarshatter-a7bba97ddbb49f626951c4cb7fb72a9ba879f64c.zip
starshatter-a7bba97ddbb49f626951c4cb7fb72a9ba879f64c.tar.gz
starshatter-a7bba97ddbb49f626951c4cb7fb72a9ba879f64c.tar.bz2
Brought NetMsg closer to standard
Diffstat (limited to 'NetEx/NetMsg.h')
-rw-r--r--NetEx/NetMsg.h61
1 files changed, 26 insertions, 35 deletions
diff --git a/NetEx/NetMsg.h b/NetEx/NetMsg.h
index 1a8585f..4e1cf18 100644
--- a/NetEx/NetMsg.h
+++ b/NetEx/NetMsg.h
@@ -3,25 +3,19 @@
Copyright (c) 2011-2012, Starshatter OpenSource Distribution Contributors
Copyright (c) 1997-2006, Destroyer Studios LLC.
- AUTHOR: John DiCamillo
+ AUTHOR: John DiCamillo
- OVERVIEW
- ========
- User level network message
+ OVERVIEW
+ ========
+ User level network message
*/
-
#ifndef NetMsg_h
#define NetMsg_h
-#include <windows.h>
-#include "NetAddr.h"
-#include "NetGram.h"
-#include "NetSock.h"
-#include "List.h"
+#include <cstdint>
-// +-------------------------------------------------------------------+
class NetMsg
{
@@ -30,52 +24,49 @@ public:
enum FLAGS { RELIABLE = 0x01, PRIORITY = 0x02, SCATTER = 0x04 };
enum TYPES { INVALID = 0,
- RESERVED = 0xF0,
- MULTIPART = 0xF1
+ RESERVED = 0xF0,
+ MULTIPART = 0xF1
};
enum { MAX_SIZE = 250 };
- NetMsg(DWORD nid, void* d, int l, BYTE f=0);
- NetMsg(DWORD nid, BYTE type, const char* text, int len, BYTE f=0);
+ NetMsg(std::uint32_t nid, void* d, int l, std::uint8_t f=0);
+ NetMsg(std::uint32_t nid, std::uint8_t type, const char* text, int len, std::uint8_t f=0);
~NetMsg();
int operator == (const NetMsg& m) const { return msgid == m.msgid &&
netid == m.netid; }
int operator < (const NetMsg& m) const;
- DWORD Sequence() const { return msgid; }
- DWORD NetID() const { return netid; }
- const BYTE* Data() const { return data; }
- BYTE Type() const { return data ? *data : 0; }
- int Length() const { return len; }
- BYTE Flags() const { return flags; }
+ std::uint32_t Sequence() const { return msgid; }
+ std::uint32_t NetID() const { return netid; }
+ const std::uint8_t* Data() const { return data; }
+ std::uint8_t Type() const { return data ? *data : 0; }
+ int Length() const { return len; }
+ std::uint8_t Flags() const { return flags; }
bool IsReliable() const { return flags & RELIABLE ? true : false; }
bool IsPriority() const { return flags & PRIORITY ? true : false; }
bool IsScatter() const { return flags & SCATTER ? true : false; }
- void SetSequence(DWORD s) { msgid = s; }
+ void SetSequence(std::uint32_t s) { msgid = s; }
private:
- DWORD msgid;
- DWORD netid;
- BYTE* data;
+ std::uint32_t msgid;
+ std::uint32_t netid;
+ std::uint8_t* data;
int len;
- BYTE flags;
+ std::uint8_t flags;
};
-// +-------------------------------------------------------------------+
struct NetMsgMultipart {
- BYTE type;
- BYTE len;
- DWORD msgid;
- DWORD partno;
- DWORD nparts;
- BYTE payload[256];
+ std::uint8_t type;
+ std::uint8_t len;
+ std::uint32_t msgid;
+ std::uint32_t partno;
+ std::uint32_t nparts;
+ std::uint8_t payload[256];
};
-// +-------------------------------------------------------------------+
-
#endif // NetMsg_h