Skip to content

Commit

Permalink
Merge pull request #987 from openmultiplayer/hual/GetTickCount_windows
Browse files Browse the repository at this point in the history
GetTickCount on Windows to return tick count of server instead of system
  • Loading branch information
AmyrAhmady authored Sep 23, 2024
2 parents 14c7971 + 0c10a13 commit b4d411c
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion Server/Source/util.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -118,6 +119,7 @@ unsigned GetTickCount()
{
#ifdef BUILD_WINDOWS
QueryPerformanceFrequency(&yo);
QueryPerformanceCounter(&initialTime);
#else
gettimeofday(&initialTime, 0);
#endif
Expand All @@ -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);
Expand Down

0 comments on commit b4d411c

Please sign in to comment.