summaryrefslogtreecommitdiffhomepage
path: root/NetEx/NetMsg.cpp
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.cpp
parentacecd34e8ffe8c77a6e7fb4f0fa9b8375a0d176a (diff)
downloadstarshatter-a7bba97ddbb49f626951c4cb7fb72a9ba879f64c.zip
starshatter-a7bba97ddbb49f626951c4cb7fb72a9ba879f64c.tar.gz
starshatter-a7bba97ddbb49f626951c4cb7fb72a9ba879f64c.tar.bz2
Brought NetMsg closer to standard
Diffstat (limited to 'NetEx/NetMsg.cpp')
-rw-r--r--NetEx/NetMsg.cpp44
1 files changed, 24 insertions, 20 deletions
diff --git a/NetEx/NetMsg.cpp b/NetEx/NetMsg.cpp
index 63489d9..4e775da 100644
--- a/NetEx/NetMsg.cpp
+++ b/NetEx/NetMsg.cpp
@@ -3,30 +3,33 @@
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
*/
-#include <windows.h>
#include "NetMsg.h"
-// +-------------------------------------------------------------------+
+#include <cstdint>
+#include <cstring>
-static DWORD net_msg_sequence = 1;
-// +-------------------------------------------------------------------+
+static std::uint32_t net_msg_sequence = 1;
-NetMsg::NetMsg(DWORD nid, void* d, int l, BYTE f)
- : msgid(net_msg_sequence++), netid(nid), len(l), flags(f)
+
+NetMsg::NetMsg(std::uint32_t nid, void* d, int l, std::uint8_t f) :
+ msgid(net_msg_sequence++),
+ netid(nid),
+ len(l),
+ flags(f)
{
- data = new BYTE[len];
+ data = new std::uint8_t[len];
if (data) {
- CopyMemory(data, d, len);
+ std::memcpy(data, d, len);
if (len < MAX_SIZE)
data[1] = len;
@@ -38,12 +41,14 @@ NetMsg::NetMsg(DWORD nid, void* d, int l, BYTE f)
}
}
-// +-------------------------------------------------------------------+
-NetMsg::NetMsg(DWORD nid, BYTE type, const char* text, int l, BYTE f)
- : msgid(net_msg_sequence++), netid(nid), len(2+l), flags(f)
+NetMsg::NetMsg(std::uint32_t nid, std::uint8_t type, const char* text, int l, std::uint8_t f) :
+ msgid(net_msg_sequence++),
+ netid(nid),
+ len(2+l),
+ flags(f)
{
- data = new BYTE[len];
+ data = new std::uint8_t[len];
if (data) {
data[0] = type;
@@ -54,23 +59,22 @@ NetMsg::NetMsg(DWORD nid, BYTE type, const char* text, int l, BYTE f)
data[1] = 0;
if (len > 2)
- CopyMemory(data+2, text, len-2);
+ std::memcpy(data + 2, text, len - 2);
}
else {
len = 0;
}
}
-// +-------------------------------------------------------------------+
NetMsg::~NetMsg()
{
delete [] data;
}
-// +-------------------------------------------------------------------+
-int NetMsg::operator < (const NetMsg& m) const
+int
+NetMsg::operator < (const NetMsg& m) const
{
if (data[0] == MULTIPART && m.data[0] == MULTIPART) {
NetMsgMultipart* p1 = (NetMsgMultipart*) data;