Beispiel #1
0
static void seedAllTimers()
{
  if(!TimersSeeded)
  {
    EnterCriticalSection(&TimerSeedLock);

    if(!TimersSeeded)
    {
      Real_QueryPerformanceCounter(&firstTimeQPC);
      firstTimeTGT = Real_timeGetTime();
      Real_GetSystemTimeAsFileTime(&firstTimeGSTAFT);

      // never actually mark timers as seeded in the first frame (i.e. before anything
      // was presented) - you get problems with config dialogs etc. otherweise
      TimersSeeded = getFrameTiming() != 0;
    }

    LeaveCriticalSection(&TimerSeedLock);
  }
}
Beispiel #2
0
static BOOL WINAPI Mine_QueryPerformanceCounter(LARGE_INTEGER *lpPerformanceCount)
{
	BOOL bResult = Real_QueryPerformanceCounter(lpPerformanceCount);

	EnterCriticalSection(&g_csQueryPerformanceCounter);
	static LARGE_INTEGER liLastCount = {0};
	static LARGE_INTEGER liLastResult = {0};
	if (liLastCount.QuadPart == 0)
	{
		liLastCount.QuadPart = lpPerformanceCount->QuadPart;
		liLastResult.QuadPart = lpPerformanceCount->QuadPart;
	}
	else
	{
		liLastResult.QuadPart += (LONGLONG)((lpPerformanceCount->QuadPart - liLastCount.QuadPart) * g_fSpeed + 0.5);
		liLastCount.QuadPart = lpPerformanceCount->QuadPart;
		lpPerformanceCount->QuadPart = liLastResult.QuadPart;
	}
	LeaveCriticalSection(&g_csQueryPerformanceCounter);
	return bResult;
}