Browse Source

Work towards killing TimeGetMs.

Only remaining uses are in pnAsyncCore stuff, and I'm not touching that
until the std::thread merge is figured out.
Darryl Pogue 11 years ago
parent
commit
a0da984cdc
  1. 2
      Sources/Plasma/NucleusLib/pnNetCli/pnNetCli.h
  2. 1
      Sources/Plasma/PubUtilLib/plNetGameLib/Pch.h
  3. 4
      Sources/Plasma/PubUtilLib/plNetGameLib/Private/plNglAuth.cpp
  4. 14
      Sources/Plasma/PubUtilLib/plNetGameLib/Private/plNglFile.cpp
  5. 2
      Sources/Plasma/PubUtilLib/plNetGameLib/Private/plNglGame.cpp
  6. 4
      Sources/Plasma/PubUtilLib/plNetGameLib/Private/plNglGateKeeper.cpp
  7. 8
      Sources/Plasma/PubUtilLib/plNetGameLib/Private/plNglTrans.cpp
  8. 2
      Sources/Plasma/PubUtilLib/plVault/plVaultClientApi.cpp

2
Sources/Plasma/NucleusLib/pnNetCli/pnNetCli.h

@ -193,7 +193,7 @@ How to create a message sender/receiver:
static void SendPing (NetCli player) { static void SendPing (NetCli player) {
const uintptr_t msgPing[] = { const uintptr_t msgPing[] = {
kMsgPing, kMsgPing,
TimeGetMs(), hsTimer::GetMilliSeconds<uint32_t>(),
}; };
NetCliSend(player, msgPing, arrsize(msgPing)); NetCliSend(player, msgPing, arrsize(msgPing));
} }

1
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 "pnNetCli/pnNetCli.h"
#include "plProduct.h" #include "plProduct.h"
#include "hsThread.h" #include "hsThread.h"
#include "hsTimer.h"
#define USES_PROTOCOL_CLI2AUTH #define USES_PROTOCOL_CLI2AUTH
#define USES_PROTOCOL_CLI2GAME #define USES_PROTOCOL_CLI2GAME

4
Sources/Plasma/PubUtilLib/plNetGameLib/Private/plNglAuth.cpp

@ -1272,7 +1272,7 @@ static ENetError FixupPlayerName (wchar_t * name) {
//=========================================================================== //===========================================================================
static unsigned GetNonZeroTimeMs () { static unsigned GetNonZeroTimeMs () {
if (unsigned ms = TimeGetMs()) if (unsigned ms = hsTimer::GetMilliSeconds<uint32_t>())
return ms; return ms;
return 1; return 1;
} }
@ -2523,7 +2523,7 @@ bool PingRequestTrans::Recv (
const Auth2Cli_PingReply & reply = *(const Auth2Cli_PingReply *)msg; const Auth2Cli_PingReply & reply = *(const Auth2Cli_PingReply *)msg;
m_payload.Set(reply.payload, reply.payloadBytes); m_payload.Set(reply.payload, reply.payloadBytes);
m_replyAtMs = TimeGetMs(); m_replyAtMs = hsTimer::GetMilliSeconds<uint32_t>();
m_result = kNetSuccess; m_result = kNetSuccess;
m_state = kTransStateComplete; m_state = kTransStateComplete;

14
Sources/Plasma/PubUtilLib/plNetGameLib/Private/plNglFile.cpp

@ -243,7 +243,7 @@ const unsigned kMinValidConnectionMs = 25 * 1000;
//=========================================================================== //===========================================================================
static unsigned GetNonZeroTimeMs () { static unsigned GetNonZeroTimeMs () {
if (unsigned ms = TimeGetMs()) if (unsigned ms = hsTimer::GetMilliSeconds<uint32_t>())
return ms; return ms;
return 1; return 1;
} }
@ -299,7 +299,7 @@ static void UnlinkAndAbandonConn_CS (CliFileConn * conn) {
static void NotifyConnSocketConnect (CliFileConn * conn) { static void NotifyConnSocketConnect (CliFileConn * conn) {
conn->TransferRef("Connecting", "Connected"); conn->TransferRef("Connecting", "Connected");
conn->connectStartMs = TimeGetMs(); conn->connectStartMs = hsTimer::GetMilliSeconds<uint32_t>();
conn->numFailedConnects = 0; conn->numFailedConnects = 0;
// Make this the active server // Make this the active server
@ -372,7 +372,7 @@ static void NotifyConnSocketDisconnect (CliFileConn * conn) {
#ifdef SERVER #ifdef SERVER
{ {
if (TimeGetMs() - conn->connectStartMs > kMinValidConnectionMs) if (hsTimer::GetMilliSeconds<uint32_t>() - conn->connectStartMs > kMinValidConnectionMs)
conn->reconnectStartMs = 0; conn->reconnectStartMs = 0;
else else
conn->reconnectStartMs = GetNonZeroTimeMs() + kMaxReconnectIntervalMs; conn->reconnectStartMs = GetNonZeroTimeMs() + kMaxReconnectIntervalMs;
@ -386,7 +386,7 @@ static void NotifyConnSocketDisconnect (CliFileConn * conn) {
// less time elapsed then the connection was likely to a server // less time elapsed then the connection was likely to a server
// with an open port but with no notification procedure registered // with an open port but with no notification procedure registered
// for this type of communication channel. // for this type of communication channel.
if (TimeGetMs() - conn->connectStartMs > kMinValidConnectionMs) { if (hsTimer::GetMilliSeconds<uint32_t>() - conn->connectStartMs > kMinValidConnectionMs) {
conn->reconnectStartMs = 0; conn->reconnectStartMs = 0;
} }
else { else {
@ -400,7 +400,7 @@ static void NotifyConnSocketDisconnect (CliFileConn * conn) {
// send us to a new server, therefore attempt a reconnection to the same // 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 // address even if the disconnect was immediate. This is safe because the
// file server is stateless with respect to clients. // file server is stateless with respect to clients.
if (TimeGetMs() - conn->connectStartMs <= kMinValidConnectionMs) { if (hsTimer::GetMilliSeconds<uint32_t>() - conn->connectStartMs <= kMinValidConnectionMs) {
if (++conn->numImmediateDisconnects < kMaxImmediateDisconnects) if (++conn->numImmediateDisconnects < kMaxImmediateDisconnects)
conn->reconnectStartMs = GetNonZeroTimeMs() + kMaxReconnectIntervalMs; conn->reconnectStartMs = GetNonZeroTimeMs() + kMaxReconnectIntervalMs;
else else
@ -963,7 +963,7 @@ bool ManifestRequestTrans::Recv (
const uint8_t msg[], const uint8_t msg[],
unsigned bytes unsigned bytes
) { ) {
m_timeoutAtMs = TimeGetMs() + NetTransGetTimeoutMs(); // Reset the timeout counter m_timeoutAtMs = hsTimer::GetMilliSeconds<uint32_t>() + NetTransGetTimeoutMs(); // Reset the timeout counter
const File2Cli_ManifestReply & reply = *(const File2Cli_ManifestReply *) msg; const File2Cli_ManifestReply & reply = *(const File2Cli_ManifestReply *) msg;
@ -1178,7 +1178,7 @@ bool DownloadRequestTrans::Recv (
const uint8_t msg[], const uint8_t msg[],
unsigned bytes unsigned bytes
) { ) {
m_timeoutAtMs = TimeGetMs() + NetTransGetTimeoutMs(); // Reset the timeout counter m_timeoutAtMs = hsTimer::GetMilliSeconds<uint32_t>() + NetTransGetTimeoutMs(); // Reset the timeout counter
const File2Cli_FileDownloadReply & reply = *(const File2Cli_FileDownloadReply *) msg; const File2Cli_FileDownloadReply & reply = *(const File2Cli_FileDownloadReply *) msg;

2
Sources/Plasma/PubUtilLib/plNetGameLib/Private/plNglGame.cpp

@ -167,7 +167,7 @@ static std::atomic<long> s_perf[kNumPerf];
//=========================================================================== //===========================================================================
static unsigned GetNonZeroTimeMs () { static unsigned GetNonZeroTimeMs () {
if (unsigned ms = TimeGetMs()) if (unsigned ms = hsTimer::GetMilliSeconds<uint32_t>())
return ms; return ms;
return 1; return 1;
} }

4
Sources/Plasma/PubUtilLib/plNetGameLib/Private/plNglGateKeeper.cpp

@ -200,7 +200,7 @@ static std::atomic<long> s_perf[kNumPerf];
//=========================================================================== //===========================================================================
static unsigned GetNonZeroTimeMs () { static unsigned GetNonZeroTimeMs () {
if (unsigned ms = TimeGetMs()) if (unsigned ms = hsTimer::GetMilliSeconds<uint32_t>())
return ms; return ms;
return 1; return 1;
} }
@ -812,7 +812,7 @@ bool PingRequestTrans::Recv (
const GateKeeper2Cli_PingReply & reply = *(const GateKeeper2Cli_PingReply *)msg; const GateKeeper2Cli_PingReply & reply = *(const GateKeeper2Cli_PingReply *)msg;
m_payload.Set(reply.payload, reply.payloadBytes); m_payload.Set(reply.payload, reply.payloadBytes);
m_replyAtMs = TimeGetMs(); m_replyAtMs = hsTimer::GetMilliSeconds<uint32_t>();
m_result = kNetSuccess; m_result = kNetSuccess;
m_state = kTransStateComplete; m_state = kTransStateComplete;

8
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. return true; // transaction was canceled.
// Update the timeout time // Update the timeout time
trans->m_timeoutAtMs = TimeGetMs() + s_timeoutMs; trans->m_timeoutAtMs = hsTimer::GetMilliSeconds<uint32_t>() + s_timeoutMs;
bool result = trans->Recv(msg, bytes); bool result = trans->Recv(msg, bytes);
@ -315,7 +315,7 @@ void NetTransUpdate () {
// This is the default "next state", trans->Send() can override this // This is the default "next state", trans->Send() can override this
trans->m_state = kTransStateWaitServerResponse; trans->m_state = kTransStateWaitServerResponse;
// Set timeout time before calling Send(), allowing Send() to change it if it wants to. // 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<uint32_t>() + s_timeoutMs;
if (!trans->Send()) { if (!trans->Send()) {
// Revert back to current state so that we'll attempt to send again // Revert back to current state so that we'll attempt to send again
trans->m_state = kTransStateWaitServerConnect; trans->m_state = kTransStateWaitServerConnect;
@ -326,12 +326,12 @@ void NetTransUpdate () {
case kTransStateWaitServerResponse: case kTransStateWaitServerResponse:
// Check for timeout // Check for timeout
if ((int)(TimeGetMs() - trans->m_timeoutAtMs) > 0) { if ((int)(hsTimer::GetMilliSeconds<uint32_t>() - trans->m_timeoutAtMs) > 0) {
// Check to see if the transaction wants to "abort" the timeout // Check to see if the transaction wants to "abort" the timeout
if (trans->TimedOut()) if (trans->TimedOut())
CancelTrans_CS(trans, kNetErrTimeout); CancelTrans_CS(trans, kNetErrTimeout);
else else
trans->m_timeoutAtMs = TimeGetMs() + s_timeoutMs; // Reset the timeout counter trans->m_timeoutAtMs = hsTimer::GetMilliSeconds<uint32_t>() + s_timeoutMs; // Reset the timeout counter
} }
done = true; done = true;
break; break;

2
Sources/Plasma/PubUtilLib/plVault/plVaultClientApi.cpp

@ -729,7 +729,7 @@ static void SaveDirtyNodes () {
static const unsigned kSaveUpdateIntervalMs = 250; static const unsigned kSaveUpdateIntervalMs = 250;
static const unsigned kMaxBytesPerSaveUpdate = 5 * 1024; static const unsigned kMaxBytesPerSaveUpdate = 5 * 1024;
static unsigned s_nextSaveMs; static unsigned s_nextSaveMs;
unsigned currTimeMs = TimeGetMs() | 1; unsigned currTimeMs = hsTimer::GetMilliSeconds<uint32_t>() | 1;
if (!s_nextSaveMs || signed(s_nextSaveMs - currTimeMs) <= 0) { if (!s_nextSaveMs || signed(s_nextSaveMs - currTimeMs) <= 0) {
s_nextSaveMs = (currTimeMs + kSaveUpdateIntervalMs) | 1; s_nextSaveMs = (currTimeMs + kSaveUpdateIntervalMs) | 1;
unsigned bytesWritten = 0; unsigned bytesWritten = 0;

Loading…
Cancel
Save