From 1c9c2eededb26c27544480202694e29cddb0a497 Mon Sep 17 00:00:00 2001 From: kaetemi Date: Fri, 27 Jul 2012 22:33:07 +0200 Subject: [PATCH] Changed: Simplify some things --- code/nel/include/nel/misc/time_nl.h | 2 +- code/nel/src/misc/time_nl.cpp | 20 ++++---------------- 2 files changed, 5 insertions(+), 17 deletions(-) diff --git a/code/nel/include/nel/misc/time_nl.h b/code/nel/include/nel/misc/time_nl.h index 62161e304..ac9ea619c 100644 --- a/code/nel/include/nel/misc/time_nl.h +++ b/code/nel/include/nel/misc/time_nl.h @@ -84,7 +84,7 @@ public: * the value can jump backwards if the system time is changed by a user or a NTP time sync process. * The value is different on 2 different computers; use the CUniTime class to get a universal * time that is the same on all computers. - * \warning On Win32, the value is on 32 bits only. It wraps around to 0 every about 49.71 days. + * \warning On Win32, the value is on 32 bits only, and uses the low-res timer. It wraps around to 0 every about 49.71 days. */ static TTime getLocalTime(); diff --git a/code/nel/src/misc/time_nl.cpp b/code/nel/src/misc/time_nl.cpp index 11a920a79..065db103e 100644 --- a/code/nel/src/misc/time_nl.cpp +++ b/code/nel/src/misc/time_nl.cpp @@ -40,6 +40,7 @@ namespace NLMISC namespace { #ifdef NL_OS_WINDOWS bool a_HaveQueryPerformance = false; +LARGE_INTEGER a_QueryPerformanceFrequency; #endif } @@ -72,6 +73,7 @@ void CTime::probeTimerInfo(CTime::CTimerInfo &result) result.HighPrecisionResolution = 1000; } a_HaveQueryPerformance = result.IsHighPrecisionAvailable; + a_QueryPerformanceFrequency.QuadPart = winPerfFreq.QuadPart; if (!result.IsHighPrecisionAvailable) { lowResTime = timeGetTime(); @@ -299,20 +301,6 @@ TTime CTime::getLocalTime () #endif } -#ifdef NL_OS_WINDOWS -namespace { -struct CQPFProvider -{ - CQPFProvider() - { - QueryPerformanceFrequency(&Frequency); - } - LARGE_INTEGER Frequency; -}; -CQPFProvider s_QPFProvider; -} -#endif - /// Same as above but prefer high resolution timer TTime CTime::getLocalTimeHR() { @@ -323,8 +311,8 @@ TTime CTime::getLocalTimeHR() // If my calculations are right. LARGE_INTEGER counter; QueryPerformanceCounter(&counter); - counter.QuadPart *= 1000; - counter.QuadPart /= s_QPFProvider.Frequency.QuadPart; + counter.QuadPart *= (LONGLONG)1000L; + counter.QuadPart /= a_QueryPerformanceFrequency.QuadPart; } else {