diff --git a/Sources/Plasma/NucleusLib/pnNetCli/pnNetCli.h b/Sources/Plasma/NucleusLib/pnNetCli/pnNetCli.h index b15cb434..4d7319b7 100644 --- a/Sources/Plasma/NucleusLib/pnNetCli/pnNetCli.h +++ b/Sources/Plasma/NucleusLib/pnNetCli/pnNetCli.h @@ -193,7 +193,7 @@ How to create a message sender/receiver: static void SendPing (NetCli player) { const uintptr_t msgPing[] = { kMsgPing, - TimeGetMs(), + hsTimer::GetMilliSeconds(), }; NetCliSend(player, msgPing, arrsize(msgPing)); } diff --git a/Sources/Plasma/PubUtilLib/plNetGameLib/Pch.h b/Sources/Plasma/PubUtilLib/plNetGameLib/Pch.h index 7509f12b..0e4e0e90 100644 --- a/Sources/Plasma/PubUtilLib/plNetGameLib/Pch.h +++ b/Sources/Plasma/PubUtilLib/plNetGameLib/Pch.h @@ -57,6 +57,7 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com #include "pnNetCli/pnNetCli.h" #include "plProduct.h" #include "hsThread.h" +#include "hsTimer.h" #define USES_PROTOCOL_CLI2AUTH #define USES_PROTOCOL_CLI2GAME diff --git a/Sources/Plasma/PubUtilLib/plNetGameLib/Private/plNglAuth.cpp b/Sources/Plasma/PubUtilLib/plNetGameLib/Private/plNglAuth.cpp index b93b55d5..6da89ab4 100644 --- a/Sources/Plasma/PubUtilLib/plNetGameLib/Private/plNglAuth.cpp +++ b/Sources/Plasma/PubUtilLib/plNetGameLib/Private/plNglAuth.cpp @@ -1272,7 +1272,7 @@ static ENetError FixupPlayerName (wchar_t * name) { //=========================================================================== static unsigned GetNonZeroTimeMs () { - if (unsigned ms = TimeGetMs()) + if (unsigned ms = hsTimer::GetMilliSeconds()) return ms; return 1; } @@ -2523,7 +2523,7 @@ bool PingRequestTrans::Recv ( const Auth2Cli_PingReply & reply = *(const Auth2Cli_PingReply *)msg; m_payload.Set(reply.payload, reply.payloadBytes); - m_replyAtMs = TimeGetMs(); + m_replyAtMs = hsTimer::GetMilliSeconds(); m_result = kNetSuccess; m_state = kTransStateComplete; diff --git a/Sources/Plasma/PubUtilLib/plNetGameLib/Private/plNglFile.cpp b/Sources/Plasma/PubUtilLib/plNetGameLib/Private/plNglFile.cpp index a808f4ac..3580379f 100644 --- a/Sources/Plasma/PubUtilLib/plNetGameLib/Private/plNglFile.cpp +++ b/Sources/Plasma/PubUtilLib/plNetGameLib/Private/plNglFile.cpp @@ -243,7 +243,7 @@ const unsigned kMinValidConnectionMs = 25 * 1000; //=========================================================================== static unsigned GetNonZeroTimeMs () { - if (unsigned ms = TimeGetMs()) + if (unsigned ms = hsTimer::GetMilliSeconds()) return ms; return 1; } @@ -299,7 +299,7 @@ static void UnlinkAndAbandonConn_CS (CliFileConn * conn) { static void NotifyConnSocketConnect (CliFileConn * conn) { conn->TransferRef("Connecting", "Connected"); - conn->connectStartMs = TimeGetMs(); + conn->connectStartMs = hsTimer::GetMilliSeconds(); conn->numFailedConnects = 0; // Make this the active server @@ -372,7 +372,7 @@ static void NotifyConnSocketDisconnect (CliFileConn * conn) { #ifdef SERVER { - if (TimeGetMs() - conn->connectStartMs > kMinValidConnectionMs) + if (hsTimer::GetMilliSeconds() - conn->connectStartMs > kMinValidConnectionMs) conn->reconnectStartMs = 0; else conn->reconnectStartMs = GetNonZeroTimeMs() + kMaxReconnectIntervalMs; @@ -386,7 +386,7 @@ static void NotifyConnSocketDisconnect (CliFileConn * conn) { // less time elapsed then the connection was likely to a server // with an open port but with no notification procedure registered // for this type of communication channel. - if (TimeGetMs() - conn->connectStartMs > kMinValidConnectionMs) { + if (hsTimer::GetMilliSeconds() - conn->connectStartMs > kMinValidConnectionMs) { conn->reconnectStartMs = 0; } else { @@ -400,7 +400,7 @@ static void NotifyConnSocketDisconnect (CliFileConn * conn) { // send us to a new server, therefore attempt a reconnection to the same // address even if the disconnect was immediate. This is safe because the // file server is stateless with respect to clients. - if (TimeGetMs() - conn->connectStartMs <= kMinValidConnectionMs) { + if (hsTimer::GetMilliSeconds() - conn->connectStartMs <= kMinValidConnectionMs) { if (++conn->numImmediateDisconnects < kMaxImmediateDisconnects) conn->reconnectStartMs = GetNonZeroTimeMs() + kMaxReconnectIntervalMs; else @@ -963,7 +963,7 @@ bool ManifestRequestTrans::Recv ( const uint8_t msg[], unsigned bytes ) { - m_timeoutAtMs = TimeGetMs() + NetTransGetTimeoutMs(); // Reset the timeout counter + m_timeoutAtMs = hsTimer::GetMilliSeconds() + NetTransGetTimeoutMs(); // Reset the timeout counter const File2Cli_ManifestReply & reply = *(const File2Cli_ManifestReply *) msg; @@ -1178,7 +1178,7 @@ bool DownloadRequestTrans::Recv ( const uint8_t msg[], unsigned bytes ) { - m_timeoutAtMs = TimeGetMs() + NetTransGetTimeoutMs(); // Reset the timeout counter + m_timeoutAtMs = hsTimer::GetMilliSeconds() + NetTransGetTimeoutMs(); // Reset the timeout counter const File2Cli_FileDownloadReply & reply = *(const File2Cli_FileDownloadReply *) msg; diff --git a/Sources/Plasma/PubUtilLib/plNetGameLib/Private/plNglGame.cpp b/Sources/Plasma/PubUtilLib/plNetGameLib/Private/plNglGame.cpp index 49e5d79a..a2f38124 100644 --- a/Sources/Plasma/PubUtilLib/plNetGameLib/Private/plNglGame.cpp +++ b/Sources/Plasma/PubUtilLib/plNetGameLib/Private/plNglGame.cpp @@ -167,7 +167,7 @@ static std::atomic s_perf[kNumPerf]; //=========================================================================== static unsigned GetNonZeroTimeMs () { - if (unsigned ms = TimeGetMs()) + if (unsigned ms = hsTimer::GetMilliSeconds()) return ms; return 1; } diff --git a/Sources/Plasma/PubUtilLib/plNetGameLib/Private/plNglGateKeeper.cpp b/Sources/Plasma/PubUtilLib/plNetGameLib/Private/plNglGateKeeper.cpp index 91fc7a0c..52a5beee 100644 --- a/Sources/Plasma/PubUtilLib/plNetGameLib/Private/plNglGateKeeper.cpp +++ b/Sources/Plasma/PubUtilLib/plNetGameLib/Private/plNglGateKeeper.cpp @@ -200,7 +200,7 @@ static std::atomic s_perf[kNumPerf]; //=========================================================================== static unsigned GetNonZeroTimeMs () { - if (unsigned ms = TimeGetMs()) + if (unsigned ms = hsTimer::GetMilliSeconds()) return ms; return 1; } @@ -812,7 +812,7 @@ bool PingRequestTrans::Recv ( const GateKeeper2Cli_PingReply & reply = *(const GateKeeper2Cli_PingReply *)msg; m_payload.Set(reply.payload, reply.payloadBytes); - m_replyAtMs = TimeGetMs(); + m_replyAtMs = hsTimer::GetMilliSeconds(); m_result = kNetSuccess; m_state = kTransStateComplete; diff --git a/Sources/Plasma/PubUtilLib/plNetGameLib/Private/plNglTrans.cpp b/Sources/Plasma/PubUtilLib/plNetGameLib/Private/plNglTrans.cpp index aa611a1d..da63017f 100644 --- a/Sources/Plasma/PubUtilLib/plNetGameLib/Private/plNglTrans.cpp +++ b/Sources/Plasma/PubUtilLib/plNetGameLib/Private/plNglTrans.cpp @@ -219,7 +219,7 @@ bool NetTransRecv (unsigned transId, const uint8_t msg[], unsigned bytes) { return true; // transaction was canceled. // Update the timeout time - trans->m_timeoutAtMs = TimeGetMs() + s_timeoutMs; + trans->m_timeoutAtMs = hsTimer::GetMilliSeconds() + s_timeoutMs; bool result = trans->Recv(msg, bytes); @@ -315,7 +315,7 @@ void NetTransUpdate () { // This is the default "next state", trans->Send() can override this trans->m_state = kTransStateWaitServerResponse; // Set timeout time before calling Send(), allowing Send() to change it if it wants to. - trans->m_timeoutAtMs = TimeGetMs() + s_timeoutMs; + trans->m_timeoutAtMs = hsTimer::GetMilliSeconds() + s_timeoutMs; if (!trans->Send()) { // Revert back to current state so that we'll attempt to send again trans->m_state = kTransStateWaitServerConnect; @@ -326,12 +326,12 @@ void NetTransUpdate () { case kTransStateWaitServerResponse: // Check for timeout - if ((int)(TimeGetMs() - trans->m_timeoutAtMs) > 0) { + if ((int)(hsTimer::GetMilliSeconds() - trans->m_timeoutAtMs) > 0) { // Check to see if the transaction wants to "abort" the timeout if (trans->TimedOut()) CancelTrans_CS(trans, kNetErrTimeout); else - trans->m_timeoutAtMs = TimeGetMs() + s_timeoutMs; // Reset the timeout counter + trans->m_timeoutAtMs = hsTimer::GetMilliSeconds() + s_timeoutMs; // Reset the timeout counter } done = true; break; diff --git a/Sources/Plasma/PubUtilLib/plVault/plVaultClientApi.cpp b/Sources/Plasma/PubUtilLib/plVault/plVaultClientApi.cpp index 3a4ec3ec..fb955d69 100644 --- a/Sources/Plasma/PubUtilLib/plVault/plVaultClientApi.cpp +++ b/Sources/Plasma/PubUtilLib/plVault/plVaultClientApi.cpp @@ -729,7 +729,7 @@ static void SaveDirtyNodes () { static const unsigned kSaveUpdateIntervalMs = 250; static const unsigned kMaxBytesPerSaveUpdate = 5 * 1024; static unsigned s_nextSaveMs; - unsigned currTimeMs = TimeGetMs() | 1; + unsigned currTimeMs = hsTimer::GetMilliSeconds() | 1; if (!s_nextSaveMs || signed(s_nextSaveMs - currTimeMs) <= 0) { s_nextSaveMs = (currTimeMs + kSaveUpdateIntervalMs) | 1; unsigned bytesWritten = 0;