From acecd34e8ffe8c77a6e7fb4f0fa9b8375a0d176a Mon Sep 17 00:00:00 2001 From: Aki Date: Wed, 30 Mar 2022 23:42:15 +0200 Subject: Brought NetLink closer to standard --- NetEx/NetLink.h | 84 +++++++++++++++++++++++++++------------------------------ 1 file changed, 40 insertions(+), 44 deletions(-) (limited to 'NetEx/NetLink.h') diff --git a/NetEx/NetLink.h b/NetEx/NetLink.h index 33024f3..5f5d081 100644 --- a/NetEx/NetLink.h +++ b/NetEx/NetLink.h @@ -3,32 +3,28 @@ Copyright (c) 2011-2012, Starshatter OpenSource Distribution Contributors Copyright (c) 1997-2006, Destroyer Studios LLC. - AUTHOR: John DiCamillo + AUTHOR: John DiCamillo - OVERVIEW - ======== - Network Link for Remote Player + OVERVIEW + ======== + Network Link for Remote Player */ - #ifndef NetLink_h #define NetLink_h +#include #include +#include -#include +#include "List.h" #include "NetAddr.h" +#include "NetGram.h" +#include "NetMsg.h" +#include "NetPeer.h" #include "NetSock.h" -#include "List.h" - -// +-------------------------------------------------------------------+ - -class NetGram; -class NetMsg; -class NetPeer; -// +-------------------------------------------------------------------+ class NetLink { @@ -43,35 +39,35 @@ public: const NetAddr& GetAddress() const { return addr; } - DWORD AddPeer(const char* a, WORD p=12345); - DWORD AddPeer(DWORD a, WORD p=12345); - DWORD AddPeer(const NetAddr& a); + std::uint32_t AddPeer(const char* a, std::uint16_t p=12345); + std::uint32_t AddPeer(std::uint32_t a, std::uint16_t p=12345); + std::uint32_t AddPeer(const NetAddr& a); - bool SendMessage(DWORD nid, void* d, int l, BYTE f=0); - bool SendMessage(DWORD nid, BYTE type, const char* text, int len, BYTE f=0); + bool SendMessage(std::uint32_t nid, void* d, int l, std::uint8_t f=0); + bool SendMessage(std::uint32_t nid, std::uint8_t type, const char* text, int len, std::uint8_t f=0); bool SendMessage(NetMsg* msg); NetMsg* GetMessage(); - NetMsg* GetMessage(DWORD netid); + NetMsg* GetMessage(std::uint32_t netid); virtual void Shutdown(); - DWORD DoSendRecv(); + std::uint32_t DoSendRecv(); - DWORD GetResendInterval() const { return resend_time; } - void SetResendInterval(DWORD t) { resend_time = t; } - DWORD GetTrafficInterval() const { return traffic_time; } - void SetTrafficInterval(DWORD t) { traffic_time = t; } + std::uint32_t GetResendInterval() const { return resend_time; } + void SetResendInterval(std::uint32_t t) { resend_time = t; } + std::uint32_t GetTrafficInterval() const { return traffic_time; } + void SetTrafficInterval(std::uint32_t t) { traffic_time = t; } - DWORD GetPacketsSent() const { return packets_sent; } - DWORD GetPacketsRecv() const { return packets_recv; } - DWORD GetBytesSent() const { return bytes_sent; } - DWORD GetBytesRecv() const { return bytes_recv; } - DWORD GetRetries() const { return retries; } - DWORD GetDrops() const { return drops; } - DWORD GetLag() const { return lag; } + std::uint32_t GetPacketsSent() const { return packets_sent; } + std::uint32_t GetPacketsRecv() const { return packets_recv; } + std::uint32_t GetBytesSent() const { return bytes_sent; } + std::uint32_t GetBytesRecv() const { return bytes_recv; } + std::uint32_t GetRetries() const { return retries; } + std::uint32_t GetDrops() const { return drops; } + std::uint32_t GetLag() const { return lag; } NetPeer* FindPeer(const NetAddr& a); - NetPeer* FindPeer(DWORD netid); + NetPeer* FindPeer(std::uint32_t netid); protected: void SendNetGram(NetGram* g); @@ -90,22 +86,22 @@ protected: List recv_list; List peer_list; - HANDLE hnet; + std::thread hnet; bool shutdown; std::mutex sync; - DWORD resend_time; - DWORD traffic_time; + std::uint32_t resend_time; + std::uint32_t traffic_time; - DWORD packets_sent; - DWORD packets_recv; - DWORD bytes_sent; - DWORD bytes_recv; - DWORD retries; - DWORD drops; - DWORD lag; + std::uint32_t packets_sent; + std::uint32_t packets_recv; + std::uint32_t bytes_sent; + std::uint32_t bytes_recv; + std::uint32_t retries; + std::uint32_t drops; + std::uint32_t lag; - DWORD lag_samples[10]; + std::uint32_t lag_samples[10]; int lag_index; }; -- cgit v1.1