From 0c10a13190e08386ad426138884faaaf41ded4b8 Mon Sep 17 00:00:00 2001 From: Hual Date: Mon, 23 Sep 2024 23:15:26 +0300 Subject: [PATCH] GetTickCount on Windows to return tick count of server instead of system --- Server/Source/util.hpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Server/Source/util.hpp b/Server/Source/util.hpp index c4baf65d1..3dffeab2d 100644 --- a/Server/Source/util.hpp +++ b/Server/Source/util.hpp @@ -22,6 +22,7 @@ struct IUnknown; #define LIBRARY_OPEN(path) LoadLibrary(path) #define LIBRARY_GET_ADDR GetProcAddress #define LIBRARY_FREE FreeLibrary +static LARGE_INTEGER initialTime; static LARGE_INTEGER yo; #define BUILD_WINDOWS #else @@ -118,6 +119,7 @@ unsigned GetTickCount() { #ifdef BUILD_WINDOWS QueryPerformanceFrequency(&yo); + QueryPerformanceCounter(&initialTime); #else gettimeofday(&initialTime, 0); #endif @@ -129,7 +131,7 @@ unsigned GetTickCount() QueryPerformanceCounter(&PerfVal); - return (unsigned)(PerfVal.QuadPart * 1000 / yo.QuadPart); + return (unsigned)((PerfVal.QuadPart - initialTime.QuadPart) * 1000 / yo.QuadPart); #else struct timeval tp; gettimeofday(&tp, 0);