mirror of
https://foundry.openuru.org/gitblit/r/CWE-ou-minkata.git
synced 2025-07-17 10:52:46 +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:
@ -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;
|
||||
|
||||
|
@ -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;
|
||||
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -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;
|
||||
|
||||
|
@ -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;
|
||||
|
Reference in New Issue
Block a user