diff --git a/common/connect.cpp b/common/connect.cpp index 7b8b8848..3a3f5c46 100644 --- a/common/connect.cpp +++ b/common/connect.cpp @@ -44,7 +44,7 @@ #include //#include -#include +#include #include #include "connect.h" @@ -225,6 +225,8 @@ int ConnectionClass::Send_Packet(void* buf, int buflen, int ack_req) ((CommHeaderType*)PacketBuf)->PacketID = NumSendNoAck; } + SwapCommHeaderType((CommHeaderType*)PacketBuf); + /*------------------------------------------------------------------------ Now build the packet ------------------------------------------------------------------------*/ @@ -745,7 +747,6 @@ int ConnectionClass::Service_Receive_Queue(void) *=========================================================================*/ unsigned int ConnectionClass::Time(void) { - static struct timeb mytime; // DOS time unsigned int msec; #ifdef WWLIB32_H @@ -762,23 +763,19 @@ unsigned int ConnectionClass::Time(void) /*------------------------------------------------------------------------ Otherwise, use the DOS timer ------------------------------------------------------------------------*/ - else { - ftime(&mytime); - msec = (unsigned int)mytime.time * 1000 + (unsigned int)mytime.millitm; - return ((msec / 100) * 6); - } #else /*------------------------------------------------------------------------ If the Westwood library isn't being used, use the DOS timer. ------------------------------------------------------------------------*/ - ftime(&mytime); - msec = (unsigned int)mytime.time * 1000 + (unsigned int)mytime.millitm; - return ((msec / 100) * 6); - #endif + static auto epoch = std::chrono::steady_clock::now().time_since_epoch(); + auto now = std::chrono::steady_clock::now().time_since_epoch(); + msec = unsigned(std::chrono::duration_cast(now - epoch).count()); + + return ((msec / 100) * 6); } /* end of Time */ /***************************************************************************