From 419e6bf9902851e23b4dfe04918521c9d19be524 Mon Sep 17 00:00:00 2001 From: fusion32 Date: Thu, 26 Feb 2026 04:52:55 -0300 Subject: network code robustness This should address some quirks of both game and query manager connections while keeping roughly the same overall design. --- src/time.cc | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'src/time.cc') diff --git a/src/time.cc b/src/time.cc index b2ba545..c615462 100644 --- a/src/time.cc +++ b/src/time.cc @@ -17,6 +17,23 @@ struct tm GetLocalTimeTM(time_t t){ return result; } +int64 GetClockMonotonicMS(void){ +#if OS_WINDOWS + LARGE_INTEGER Counter, Frequency; + QueryPerformanceCounter(&Counter); + QueryPerformanceFrequency(&Frequency); + return (int64)((Counter.QuadPart * 1000) / Frequency.QuadPart); +#else + // NOTE(fusion): The coarse monotonic clock has a larger resolution but is + // supposed to be faster, even avoiding system calls in some cases. It should + // be fine for millisecond precision which is what we're using. + struct timespec Time; + clock_gettime(CLOCK_MONOTONIC_COARSE, &Time); + return ((int64)Time.tv_sec * 1000) + + ((int64)Time.tv_nsec / 1000000); +#endif +} + void GetRealTime(int *Hour, int *Minute){ struct tm LocalTime = GetLocalTimeTM(time(NULL)); *Hour = LocalTime.tm_hour; -- cgit v1.2.3