1
0
mirror of https://foundry.openuru.org/gitblit/r/CWE-ou-minkata.git synced 2025-07-17 18:59:09 +00:00

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.
This commit is contained in:
Darryl Pogue
2014-05-11 18:45:22 -07:00
parent a3ae4201a2
commit a0da984cdc
8 changed files with 19 additions and 18 deletions

View File

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

View File

@ -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

View File

@ -1272,7 +1272,7 @@ static ENetError FixupPlayerName (wchar_t * name) {
//===========================================================================
static unsigned GetNonZeroTimeMs () {
if (unsigned ms = TimeGetMs())
if (unsigned ms = hsTimer::GetMilliSeconds<uint32_t>())
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<uint32_t>();
m_result = kNetSuccess;
m_state = kTransStateComplete;

View File

@ -243,7 +243,7 @@ const unsigned kMinValidConnectionMs = 25 * 1000;
//===========================================================================
static unsigned GetNonZeroTimeMs () {
if (unsigned ms = TimeGetMs())
if (unsigned ms = hsTimer::GetMilliSeconds<uint32_t>())
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<uint32_t>();
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<uint32_t>() - 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<uint32_t>() - 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<uint32_t>() - 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<uint32_t>() + 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<uint32_t>() + NetTransGetTimeoutMs(); // Reset the timeout counter
const File2Cli_FileDownloadReply & reply = *(const File2Cli_FileDownloadReply *) msg;

View File

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

View File

@ -200,7 +200,7 @@ static std::atomic<long> s_perf[kNumPerf];
//===========================================================================
static unsigned GetNonZeroTimeMs () {
if (unsigned ms = TimeGetMs())
if (unsigned ms = hsTimer::GetMilliSeconds<uint32_t>())
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<uint32_t>();
m_result = kNetSuccess;
m_state = kTransStateComplete;

View File

@ -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<uint32_t>() + 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<uint32_t>() + 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<uint32_t>() - 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<uint32_t>() + s_timeoutMs; // Reset the timeout counter
}
done = true;
break;

View File

@ -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<uint32_t>() | 1;
if (!s_nextSaveMs || signed(s_nextSaveMs - currTimeMs) <= 0) {
s_nextSaveMs = (currTimeMs + kSaveUpdateIntervalMs) | 1;
unsigned bytesWritten = 0;