From a7bba97ddbb49f626951c4cb7fb72a9ba879f64c Mon Sep 17 00:00:00 2001 From: Aki Date: Wed, 30 Mar 2022 23:50:47 +0200 Subject: Brought NetMsg closer to standard --- NetEx/NetMsg.h | 61 +++++++++++++++++++++++++--------------------------------- 1 file changed, 26 insertions(+), 35 deletions(-) (limited to 'NetEx/NetMsg.h') 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 -#include "NetAddr.h" -#include "NetGram.h" -#include "NetSock.h" -#include "List.h" +#include -// +-------------------------------------------------------------------+ 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 -- cgit v1.1