High FPS Fixes

This commit is contained in:
Sergeanur 2021-06-24 13:47:10 +03:00
parent b8cf8c53e7
commit 14c71f39ff
9 changed files with 120 additions and 55 deletions

View File

@ -440,6 +440,9 @@ cAudioManager::IsAudioInitialised() const
void void
cAudioManager::ServiceSoundEffects() cAudioManager::ServiceSoundEffects()
{ {
#ifdef FIX_BUGS
if(CTimer::GetLogicalFramesPassed() != 0)
#endif
m_bFifthFrameFlag = (m_FrameCounter++ % 5) == 0; m_bFifthFrameFlag = (m_FrameCounter++ % 5) == 0;
if (m_nUserPause && !m_nPreviousUserPause) { if (m_nUserPause && !m_nPreviousUserPause) {
for (int32 i = 0; i < NUM_CHANNELS; i++) for (int32 i = 0; i < NUM_CHANNELS; i++)
@ -793,9 +796,9 @@ cAudioManager::AddReleasingSounds()
} }
if (!toProcess[i]) { if (!toProcess[i]) {
if (sample.m_nCounter <= 255 || !sample.m_nLoopsRemaining) { if (sample.m_nCounter <= 255 || !sample.m_nLoopsRemaining) {
if (!sample.m_nReleasingVolumeDivider) if (sample.m_nReleasingVolumeDivider == 0)
continue; continue;
if (!sample.m_nLoopCount) { if (sample.m_nLoopCount == 0) {
if (sample.m_nVolumeChange == -1) { if (sample.m_nVolumeChange == -1) {
sample.m_nVolumeChange = sample.m_nVolume / sample.m_nReleasingVolumeDivider; sample.m_nVolumeChange = sample.m_nVolume / sample.m_nReleasingVolumeDivider;
if (sample.m_nVolumeChange <= 0) if (sample.m_nVolumeChange <= 0)
@ -807,6 +810,9 @@ cAudioManager::AddReleasingSounds()
} }
sample.m_nVolume -= sample.m_nVolumeChange; sample.m_nVolume -= sample.m_nVolumeChange;
} }
#ifdef FIX_BUGS
if(CTimer::GetLogicalFramesPassed() != 0)
#endif
--sample.m_nReleasingVolumeDivider; --sample.m_nReleasingVolumeDivider;
if (m_bFifthFrameFlag) { if (m_bFifthFrameFlag) {
if (sample.m_nReleasingVolumeModificator < 20) if (sample.m_nReleasingVolumeModificator < 20)

View File

@ -1332,7 +1332,11 @@ cMusicManager::DisplayRadioStationName()
} }
else { else {
if (cDisplay == 0) return; if (cDisplay == 0) return;
#ifdef FIX_BUGS
cDisplay -= CTimer::GetLogicalFramesPassed();
#else
cDisplay--; cDisplay--;
#endif
} }
CFont::SetJustifyOff(); CFont::SetJustifyOff();

View File

@ -137,7 +137,11 @@ cAudioManager::ServicePoliceRadio()
if (!crimeReport) { if (!crimeReport) {
if (wantedLevel != 0) { if (wantedLevel != 0) {
if (nLastSeen != 0) if (nLastSeen != 0)
#ifdef FIX_BUGS
nLastSeen -= CTimer::GetLogicalFramesPassed();
#else
--nLastSeen; --nLastSeen;
#endif
else { else {
nLastSeen = m_anRandomTable[1] % 1000 + 2000; nLastSeen = m_anRandomTable[1] % 1000 + 2000;
SetupSuspectLastSeenReport(); SetupSuspectLastSeenReport();
@ -176,7 +180,11 @@ cAudioManager::ServicePoliceRadioChannel(uint8 wantedLevel)
} }
if (m_sPoliceRadioQueue.policeChannelTimer == 0) bChannelOpen = FALSE; if (m_sPoliceRadioQueue.policeChannelTimer == 0) bChannelOpen = FALSE;
if (cWait) { if (cWait) {
#ifdef FIX_BUGS
cWait -= CTimer::GetLogicalFramesPassed();
#else
--cWait; --cWait;
#endif
return; return;
} }
if (g_nMissionAudioSfx != NO_SAMPLE && !bChannelOpen) { if (g_nMissionAudioSfx != NO_SAMPLE && !bChannelOpen) {

View File

@ -181,7 +181,7 @@ const char* FrontendFilenames[][2] = {
#ifdef XBOX_MESSAGE_SCREEN #ifdef XBOX_MESSAGE_SCREEN
bool CMenuManager::m_bDialogOpen = false; bool CMenuManager::m_bDialogOpen = false;
uint32 CMenuManager::m_nDialogHideTimer = 0; uint32 CMenuManager::m_nDialogHideTimer = 0;
PauseModeTime CMenuManager::m_nDialogHideTimerPauseMode = 0; uint32 CMenuManager::m_nDialogHideTimerPauseMode = 0;
bool CMenuManager::m_bSaveWasSuccessful = false; bool CMenuManager::m_bSaveWasSuccessful = false;
wchar* CMenuManager::m_pDialogText = nil; wchar* CMenuManager::m_pDialogText = nil;
#endif #endif
@ -750,7 +750,7 @@ CMenuManager::DisplayHelperText(char *text)
return; return;
// there was a unused static bool // there was a unused static bool
static PauseModeTime LastFlash = 0; static uint32 LastFlash = 0;
int32 alpha = 255; int32 alpha = 255;
CFont::SetRightJustifyOn(); CFont::SetRightJustifyOn();
@ -1425,7 +1425,7 @@ CMenuManager::DrawStandardMenus(bool activeScreen)
} }
} }
static PauseModeTime lastBlendChange = 0; static uint32 lastBlendChange = 0;
if (m_nOptionHighlightTransitionBlend <= 255) { if (m_nOptionHighlightTransitionBlend <= 255) {
static uint32 blendChangeCounter = 0; static uint32 blendChangeCounter = 0;
if (CTimer::GetTimeInMillisecondsPauseMode() - lastBlendChange > 20 if (CTimer::GetTimeInMillisecondsPauseMode() - lastBlendChange > 20
@ -1928,7 +1928,7 @@ CMenuManager::DrawControllerBound(int32 yStart, int32 xStart, int32 unused, int8
CFont::PrintString(nextX, nextY, seperator); CFont::PrintString(nextX, nextY, seperator);
nextX += CFont::GetStringWidth(seperator, true) + bindingMargin; nextX += CFont::GetStringWidth(seperator, true) + bindingMargin;
} }
static PauseModeTime lastWaitingTextFlash = 0; static uint32 lastWaitingTextFlash = 0;
if (CTimer::GetTimeInMillisecondsPauseMode() - lastWaitingTextFlash > 150) { if (CTimer::GetTimeInMillisecondsPauseMode() - lastWaitingTextFlash > 150) {
showWaitingText = !showWaitingText; showWaitingText = !showWaitingText;
lastWaitingTextFlash = CTimer::GetTimeInMillisecondsPauseMode(); lastWaitingTextFlash = CTimer::GetTimeInMillisecondsPauseMode();
@ -1993,7 +1993,7 @@ CMenuManager::DrawControllerScreenExtraText(int yStart, int xStart, int lineHeig
CFont::PrintString(nextX, MENU_Y(yStart), TheText.Get("FEC_IBT")); CFont::PrintString(nextX, MENU_Y(yStart), TheText.Get("FEC_IBT"));
nextX = CFont::GetStringWidth(TheText.Get("FEC_IBT"), true) + spacing + nextX; nextX = CFont::GetStringWidth(TheText.Get("FEC_IBT"), true) + spacing + nextX;
} }
static PauseModeTime lastStateChange = 0; static uint32 lastStateChange = 0;
if (CTimer::GetTimeInMillisecondsPauseMode() - lastStateChange > 150) { if (CTimer::GetTimeInMillisecondsPauseMode() - lastStateChange > 150) {
waitingTextVisible = !waitingTextVisible; waitingTextVisible = !waitingTextVisible;
lastStateChange = CTimer::GetTimeInMillisecondsPauseMode(); lastStateChange = CTimer::GetTimeInMillisecondsPauseMode();
@ -2377,7 +2377,7 @@ CMenuManager::DrawBackground(bool transitionCall)
m_nOptionHighlightTransitionBlend = 0; m_nOptionHighlightTransitionBlend = 0;
} }
static PauseModeTime LastFade = 0; static uint32 LastFade = 0;
if (m_nMenuFadeAlpha < 255) { if (m_nMenuFadeAlpha < 255) {
static uint8 forceFadeInCounter = 0; static uint8 forceFadeInCounter = 0;
@ -2448,7 +2448,7 @@ CMenuManager::DrawBackground(bool transitionCall)
} }
if (m_ShowEmptyBindingError) { if (m_ShowEmptyBindingError) {
static PauseModeTime lastBindingError = CTimer::GetTimeInMillisecondsPauseMode(); static uint32 lastBindingError = CTimer::GetTimeInMillisecondsPauseMode();
static bool bindingErrorShown = false; static bool bindingErrorShown = false;
if (bindingErrorShown) { if (bindingErrorShown) {
lastBindingError = CTimer::GetTimeInMillisecondsPauseMode(); lastBindingError = CTimer::GetTimeInMillisecondsPauseMode();
@ -3332,7 +3332,7 @@ CMenuManager::PrintStats()
else else
CFont::SetScale(MENU_X(0.37f), MENU_Y(0.75f)); CFont::SetScale(MENU_X(0.37f), MENU_Y(0.75f));
static PauseModeTime lastCheck = 0; static uint32 lastCheck = 0;
if (CTimer::GetTimeInMillisecondsPauseMode() - lastCheck > 40) { if (CTimer::GetTimeInMillisecondsPauseMode() - lastCheck > 40) {
@ -3473,7 +3473,7 @@ CMenuManager::AdditionalOptionInput(bool &goBack)
switch (m_nCurrScreen) { switch (m_nCurrScreen) {
case MENUPAGE_MAP: case MENUPAGE_MAP:
{ {
static PauseModeTime lastMapTick = 0; static uint32 lastMapTick = 0;
// FIX: All those macros were hardcoded values originally. // FIX: All those macros were hardcoded values originally.
@ -3802,7 +3802,7 @@ CMenuManager::ExportStats()
void void
CMenuManager::PrintRadioSelector(void) CMenuManager::PrintRadioSelector(void)
{ {
static PauseModeTime lastRadioChange = 0; static uint32 lastRadioChange = 0;
CSprite2d::Draw2DPolygon(MENU_X_LEFT_ALIGNED(418.f), MENU_Y(MENURADIO_SELECTOR_START_Y + MENURADIO_SELECTOR_HEIGHT), CSprite2d::Draw2DPolygon(MENU_X_LEFT_ALIGNED(418.f), MENU_Y(MENURADIO_SELECTOR_START_Y + MENURADIO_SELECTOR_HEIGHT),
MENU_X_LEFT_ALIGNED(228.f), MENU_Y(MENURADIO_SELECTOR_START_Y + MENURADIO_SELECTOR_HEIGHT), MENU_X_LEFT_ALIGNED(228.f), MENU_Y(MENURADIO_SELECTOR_START_Y + MENURADIO_SELECTOR_HEIGHT),
@ -3925,7 +3925,7 @@ CMenuManager::PrintRadioSelector(void)
#endif #endif
static bool radioChangeRequested = false; static bool radioChangeRequested = false;
static PauseModeTime lastScrollCheck = 0; static uint32 lastScrollCheck = 0;
if (CTimer::GetTimeInMillisecondsPauseMode() - lastScrollCheck > 17) { if (CTimer::GetTimeInMillisecondsPauseMode() - lastScrollCheck > 17) {
if (m_ScrollRadioBy == 1) { if (m_ScrollRadioBy == 1) {
if (m_LeftMostRadioX > MENU_X_LEFT_ALIGNED(MENURADIO_ICON_FIRST_X - MENURADIO_ICON_SIZE)) { if (m_LeftMostRadioX > MENU_X_LEFT_ALIGNED(MENURADIO_ICON_FIRST_X - MENURADIO_ICON_SIZE)) {
@ -4009,7 +4009,7 @@ CMenuManager::ProcessList(bool &optionSelected, bool &goBack)
field_159 = false; field_159 = false;
} }
static PauseModeTime lastTimeClickedScrollButton = 0; static uint32 lastTimeClickedScrollButton = 0;
if (CTimer::GetTimeInMillisecondsPauseMode() - lastTimeClickedScrollButton >= 200) { if (CTimer::GetTimeInMillisecondsPauseMode() - lastTimeClickedScrollButton >= 200) {
m_bPressedPgUpOnList = false; m_bPressedPgUpOnList = false;
@ -4395,7 +4395,7 @@ CMenuManager::UserInput(void)
int curAction = aScreens[m_nCurrScreen].m_aEntries[m_nCurrOption].m_Action; int curAction = aScreens[m_nCurrScreen].m_aEntries[m_nCurrOption].m_Action;
if (CPad::GetPad(0)->GetLeft() || CPad::GetPad(0)->GetPedWalkLeftRight() < 0 || CPad::GetPad(0)->GetDPadLeft()) { if (CPad::GetPad(0)->GetLeft() || CPad::GetPad(0)->GetPedWalkLeftRight() < 0 || CPad::GetPad(0)->GetDPadLeft()) {
static PauseModeTime lastSliderDecrease = 0; static uint32 lastSliderDecrease = 0;
if (CTimer::GetTimeInMillisecondsPauseMode() - lastSliderDecrease > 150) { if (CTimer::GetTimeInMillisecondsPauseMode() - lastSliderDecrease > 150) {
if (curAction == MENUACTION_BRIGHTNESS || curAction == MENUACTION_MUSICVOLUME || if (curAction == MENUACTION_BRIGHTNESS || curAction == MENUACTION_MUSICVOLUME ||
curAction == MENUACTION_SFXVOLUME || curAction == MENUACTION_RADIO || curAction == MENUACTION_SFXVOLUME || curAction == MENUACTION_RADIO ||
@ -4406,7 +4406,7 @@ CMenuManager::UserInput(void)
lastSliderDecrease = CTimer::GetTimeInMillisecondsPauseMode(); lastSliderDecrease = CTimer::GetTimeInMillisecondsPauseMode();
} }
} else if (CPad::GetPad(0)->GetRight() || CPad::GetPad(0)->GetPedWalkLeftRight() > 0 || CPad::GetPad(0)->GetDPadRight()) { } else if (CPad::GetPad(0)->GetRight() || CPad::GetPad(0)->GetPedWalkLeftRight() > 0 || CPad::GetPad(0)->GetDPadRight()) {
static PauseModeTime lastSliderIncrease = 0; static uint32 lastSliderIncrease = 0;
if (CTimer::GetTimeInMillisecondsPauseMode() - lastSliderIncrease > 150) { if (CTimer::GetTimeInMillisecondsPauseMode() - lastSliderIncrease > 150) {
if (curAction == MENUACTION_BRIGHTNESS || curAction == MENUACTION_MUSICVOLUME || if (curAction == MENUACTION_BRIGHTNESS || curAction == MENUACTION_MUSICVOLUME ||
curAction == MENUACTION_SFXVOLUME || curAction == MENUACTION_RADIO || curAction == MENUACTION_SFXVOLUME || curAction == MENUACTION_RADIO ||
@ -5396,7 +5396,7 @@ CMenuManager::ProcessFileActions()
{ {
#ifdef XBOX_MESSAGE_SCREEN #ifdef XBOX_MESSAGE_SCREEN
if (m_bDialogOpen && DialogTextCmp("FESZ_WR")) { if (m_bDialogOpen && DialogTextCmp("FESZ_WR")) {
PauseModeTime startTime = CTimer::GetTimeInMillisecondsPauseMode(); uint32 startTime = CTimer::GetTimeInMillisecondsPauseMode();
int8 SaveSlot = PcSaveHelper.SaveSlot(m_nCurrSaveSlot); int8 SaveSlot = PcSaveHelper.SaveSlot(m_nCurrSaveSlot);
PcSaveHelper.PopulateSlotInfo(); PcSaveHelper.PopulateSlotInfo();
@ -5654,13 +5654,13 @@ CMenuManager::DrawQuitGameScreen(void)
#endif #endif
#ifndef MUCH_SHORTER_OUTRO_SCREEN #ifndef MUCH_SHORTER_OUTRO_SCREEN
static PauseModeTime lastTickIncrease = 0; static uint32 lastTickIncrease = 0;
if (alpha == 255 && CTimer::GetTimeInMillisecondsPauseMode() - lastTickIncrease > 10) { if (alpha == 255 && CTimer::GetTimeInMillisecondsPauseMode() - lastTickIncrease > 10) {
exitSignalTimer++; exitSignalTimer++;
lastTickIncrease = CTimer::GetTimeInMillisecondsPauseMode(); lastTickIncrease = CTimer::GetTimeInMillisecondsPauseMode();
} }
#else #else
static PauseModeTime firstTick = CTimer::GetTimeInMillisecondsPauseMode(); static uint32 firstTick = CTimer::GetTimeInMillisecondsPauseMode();
if (alpha == 255 && CTimer::GetTimeInMillisecondsPauseMode() - firstTick > 750) { if (alpha == 255 && CTimer::GetTimeInMillisecondsPauseMode() - firstTick > 750) {
exitSignalTimer = 150; exitSignalTimer = 150;
} }

View File

@ -735,7 +735,7 @@ public:
#ifdef XBOX_MESSAGE_SCREEN #ifdef XBOX_MESSAGE_SCREEN
static uint32 m_nDialogHideTimer; static uint32 m_nDialogHideTimer;
static PauseModeTime m_nDialogHideTimerPauseMode; static uint32 m_nDialogHideTimerPauseMode;
static bool m_bDialogOpen; static bool m_bDialogOpen;
static wchar *m_pDialogText; static wchar *m_pDialogText;
static bool m_bSaveWasSuccessful; static bool m_bSaveWasSuccessful;

View File

@ -1382,7 +1382,7 @@ CRadar::InitFrontEndMap()
void void
CRadar::DrawYouAreHereSprite(float x, float y) CRadar::DrawYouAreHereSprite(float x, float y)
{ {
static PauseModeTime lastChange = 0; static uint32 lastChange = 0;
static bool show = true; static bool show = true;
if (show) { if (show) {
@ -1582,7 +1582,7 @@ void
CRadar::DrawLegend(int32 x, int32 y, int32 sprite) CRadar::DrawLegend(int32 x, int32 y, int32 sprite)
{ {
if (sprite < 0) { if (sprite < 0) {
static PauseModeTime lastChange = 0; static uint32 lastChange = 0;
static int8 blipMode = 0; static int8 blipMode = 0;
CRGBA color; CRGBA color;

View File

@ -8,7 +8,7 @@
#include "SpecialFX.h" #include "SpecialFX.h"
uint32 CTimer::m_snTimeInMilliseconds; uint32 CTimer::m_snTimeInMilliseconds;
PauseModeTime CTimer::m_snTimeInMillisecondsPauseMode = 1; uint32 CTimer::m_snTimeInMillisecondsPauseMode = 1;
uint32 CTimer::m_snTimeInMillisecondsNonClipped; uint32 CTimer::m_snTimeInMillisecondsNonClipped;
uint32 CTimer::m_snPreviousTimeInMilliseconds; uint32 CTimer::m_snPreviousTimeInMilliseconds;
@ -18,6 +18,10 @@ float CTimer::ms_fTimeStep;
float CTimer::ms_fTimeStepNonClipped; float CTimer::ms_fTimeStepNonClipped;
bool CTimer::m_UserPause; bool CTimer::m_UserPause;
bool CTimer::m_CodePause; bool CTimer::m_CodePause;
#ifdef FIX_BUGS
uint32 CTimer::m_LogicalFrameCounter;
uint32 CTimer::m_LogicalFramesPassed;
#endif
uint32 _nCyclesPerMS = 1; uint32 _nCyclesPerMS = 1;
@ -35,10 +39,6 @@ RsTimerType suspendPcTimer;
uint32 suspendDepth; uint32 suspendDepth;
#ifdef FIX_HIGH_FPS_BUGS_ON_FRONTEND
double frameTime;
#endif
void CTimer::Initialise(void) void CTimer::Initialise(void)
{ {
debug("Initialising CTimer...\n"); debug("Initialising CTimer...\n");
@ -51,6 +51,10 @@ void CTimer::Initialise(void)
m_snTimeInMillisecondsNonClipped = 0; m_snTimeInMillisecondsNonClipped = 0;
m_snPreviousTimeInMilliseconds = 0; m_snPreviousTimeInMilliseconds = 0;
m_snTimeInMilliseconds = 1; m_snTimeInMilliseconds = 1;
#ifdef FIX_BUGS
m_LogicalFrameCounter = 0;
m_LogicalFramesPassed = 0;
#endif
#ifdef _WIN32 #ifdef _WIN32
LARGE_INTEGER perfFreq; LARGE_INTEGER perfFreq;
@ -84,6 +88,12 @@ void CTimer::Shutdown(void)
void CTimer::Update(void) void CTimer::Update(void)
{ {
#ifdef FIX_BUGS
static double frameTimeLogical = 0.0;
static double frameTimeFraction = 0.0;
static double frameTimeFractionScaled = 0.0;
#endif
m_snPreviousTimeInMilliseconds = m_snTimeInMilliseconds; m_snPreviousTimeInMilliseconds = m_snTimeInMilliseconds;
#ifdef _WIN32 #ifdef _WIN32
@ -98,22 +108,43 @@ void CTimer::Update(void)
float updInCyclesScaled = GetIsPaused() ? updInCycles : updInCycles * ms_fTimeScale; float updInCyclesScaled = GetIsPaused() ? updInCycles : updInCycles * ms_fTimeScale;
// We need that real frame time to fix transparent menu bug. double frameTime = updInCyclesScaled / (double)_nCyclesPerMS;
#ifndef FIX_HIGH_FPS_BUGS_ON_FRONTEND
double
#endif
frameTime = updInCyclesScaled / (double)_nCyclesPerMS;
#ifdef FIX_BUGS
// count frames as if we're running at 30 fps
m_LogicalFramesPassed = 0;
frameTimeLogical += ((double)updInCycles / (double)_nCyclesPerMS);
while (frameTimeLogical >= 1000.0 / 30.0) {
frameTimeLogical -= 1000.0 / 30.0;
m_LogicalFramesPassed++;
}
m_LogicalFrameCounter += m_LogicalFramesPassed;
frameTimeFraction += (double)updInCycles / (double)_nCyclesPerMS;
frameTimeFractionScaled += frameTime;
m_snTimeInMillisecondsPauseMode += uint32(frameTimeFraction);
#else
m_snTimeInMillisecondsPauseMode = m_snTimeInMillisecondsPauseMode + frameTime; m_snTimeInMillisecondsPauseMode = m_snTimeInMillisecondsPauseMode + frameTime;
#endif
if ( GetIsPaused() ) if ( GetIsPaused() )
ms_fTimeStep = 0.0f; ms_fTimeStep = 0.0f;
else else
{ {
#ifdef FIX_BUGS
m_snTimeInMilliseconds += uint32(frameTimeFractionScaled);
m_snTimeInMillisecondsNonClipped += uint32(frameTimeFractionScaled);
#else
m_snTimeInMilliseconds = m_snTimeInMilliseconds + frameTime; m_snTimeInMilliseconds = m_snTimeInMilliseconds + frameTime;
m_snTimeInMillisecondsNonClipped = m_snTimeInMillisecondsNonClipped + frameTime; m_snTimeInMillisecondsNonClipped = m_snTimeInMillisecondsNonClipped + frameTime;
#endif
ms_fTimeStep = frameTime / 1000.0f * 50.0f; ms_fTimeStep = frameTime / 1000.0f * 50.0f;
} }
#ifdef FIX_BUGS
frameTimeFraction -= uint32(frameTimeFraction);
frameTimeFractionScaled -= uint32(frameTimeFractionScaled);
#endif
} }
else else
#endif #endif
@ -122,22 +153,39 @@ void CTimer::Update(void)
RsTimerType updInMs = timer - oldPcTimer; RsTimerType updInMs = timer - oldPcTimer;
// We need that real frame time to fix transparent menu bug. double frameTime = (double)updInMs * ms_fTimeScale;
#ifndef FIX_HIGH_FPS_BUGS_ON_FRONTEND
double
#endif
frameTime = (double)updInMs * ms_fTimeScale;
oldPcTimer = timer; oldPcTimer = timer;
#ifdef FIX_BUGS
// count frames as if we're running at 30 fps
m_LogicalFramesPassed = 0;
frameTimeLogical += (double)updInMs;
while(frameTimeLogical >= 1000.0 / 30.0) {
frameTimeLogical -= 1000.0 / 30.0;
m_LogicalFramesPassed++;
}
m_LogicalFrameCounter += m_LogicalFramesPassed;
frameTimeFraction += (double)updInMs;
frameTimeFractionScaled += frameTime;
m_snTimeInMillisecondsPauseMode += uint32(frameTimeFraction);
#else
m_snTimeInMillisecondsPauseMode = m_snTimeInMillisecondsPauseMode + frameTime; m_snTimeInMillisecondsPauseMode = m_snTimeInMillisecondsPauseMode + frameTime;
#endif
if ( GetIsPaused() ) if ( GetIsPaused() )
ms_fTimeStep = 0.0f; ms_fTimeStep = 0.0f;
else else
{ {
#ifdef FIX_BUGS
m_snTimeInMilliseconds += uint32(frameTimeFractionScaled);
m_snTimeInMillisecondsNonClipped += uint32(frameTimeFractionScaled);
#else
m_snTimeInMilliseconds = m_snTimeInMilliseconds + frameTime; m_snTimeInMilliseconds = m_snTimeInMilliseconds + frameTime;
m_snTimeInMillisecondsNonClipped = m_snTimeInMillisecondsNonClipped + frameTime; m_snTimeInMillisecondsNonClipped = m_snTimeInMillisecondsNonClipped + frameTime;
#endif
ms_fTimeStep = frameTime / 1000.0f * 50.0f; ms_fTimeStep = frameTime / 1000.0f * 50.0f;
} }
} }

View File

@ -1,22 +1,20 @@
#pragma once #pragma once
#ifdef FIX_HIGH_FPS_BUGS_ON_FRONTEND
#define PauseModeTime double
#else
#define PauseModeTime uint32
#endif
class CTimer class CTimer
{ {
static uint32 m_snTimeInMilliseconds; static uint32 m_snTimeInMilliseconds;
static PauseModeTime m_snTimeInMillisecondsPauseMode; static uint32 m_snTimeInMillisecondsPauseMode;
static uint32 m_snTimeInMillisecondsNonClipped; static uint32 m_snTimeInMillisecondsNonClipped;
static uint32 m_snPreviousTimeInMilliseconds; static uint32 m_snPreviousTimeInMilliseconds;
static uint32 m_FrameCounter; static uint32 m_FrameCounter;
static float ms_fTimeScale; static float ms_fTimeScale;
static float ms_fTimeStep; static float ms_fTimeStep;
static float ms_fTimeStepNonClipped; static float ms_fTimeStepNonClipped;
#ifdef FIX_BUGS
static uint32 m_LogicalFrameCounter;
static uint32 m_LogicalFramesPassed;
#endif
public: public:
static bool m_UserPause; static bool m_UserPause;
static bool m_CodePause; static bool m_CodePause;
@ -35,7 +33,7 @@ public:
static void SetTimeInMilliseconds(uint32 t) { m_snTimeInMilliseconds = t; } static void SetTimeInMilliseconds(uint32 t) { m_snTimeInMilliseconds = t; }
static uint32 GetTimeInMillisecondsNonClipped(void) { return m_snTimeInMillisecondsNonClipped; } static uint32 GetTimeInMillisecondsNonClipped(void) { return m_snTimeInMillisecondsNonClipped; }
static void SetTimeInMillisecondsNonClipped(uint32 t) { m_snTimeInMillisecondsNonClipped = t; } static void SetTimeInMillisecondsNonClipped(uint32 t) { m_snTimeInMillisecondsNonClipped = t; }
static PauseModeTime GetTimeInMillisecondsPauseMode(void) { return m_snTimeInMillisecondsPauseMode; } static uint32 GetTimeInMillisecondsPauseMode(void) { return m_snTimeInMillisecondsPauseMode; }
static void SetTimeInMillisecondsPauseMode(uint32 t) { m_snTimeInMillisecondsPauseMode = t; } static void SetTimeInMillisecondsPauseMode(uint32 t) { m_snTimeInMillisecondsPauseMode = t; }
static uint32 GetPreviousTimeInMilliseconds(void) { return m_snPreviousTimeInMilliseconds; } static uint32 GetPreviousTimeInMilliseconds(void) { return m_snPreviousTimeInMilliseconds; }
static void SetPreviousTimeInMilliseconds(uint32 t) { m_snPreviousTimeInMilliseconds = t; } static void SetPreviousTimeInMilliseconds(uint32 t) { m_snPreviousTimeInMilliseconds = t; }
@ -67,9 +65,7 @@ public:
#ifdef FIX_BUGS #ifdef FIX_BUGS
static float GetDefaultTimeStep(void) { return 50.0f / 30.0f; } static float GetDefaultTimeStep(void) { return 50.0f / 30.0f; }
static float GetTimeStepFix(void) { return GetTimeStep() / GetDefaultTimeStep(); } static float GetTimeStepFix(void) { return GetTimeStep() / GetDefaultTimeStep(); }
static uint32 GetLogicalFrameCounter(void) { return m_LogicalFrameCounter; }
static uint32 GetLogicalFramesPassed(void) { return m_LogicalFramesPassed; }
#endif #endif
}; };
#ifdef FIX_HIGH_FPS_BUGS_ON_FRONTEND
extern double frameTime;
#endif

View File

@ -1131,8 +1131,11 @@ DisplayGameDebugText()
#endif // #ifdef DRAW_GAME_VERSION_TEXT #endif // #ifdef DRAW_GAME_VERSION_TEXT
FrameSamples++; FrameSamples++;
#ifdef FIX_HIGH_FPS_BUGS_ON_FRONTEND #ifdef FIX_BUGS
FramesPerSecondCounter += frameTime / 1000.f; // convert to seconds // this is inaccurate with over 1000 fps
static uint32 PreviousTimeInMillisecondsPauseMode = 0;
FramesPerSecondCounter += (CTimer::GetTimeInMillisecondsPauseMode() - PreviousTimeInMillisecondsPauseMode) / 1000.0f; // convert to seconds
PreviousTimeInMillisecondsPauseMode = CTimer::GetTimeInMillisecondsPauseMode();
FramesPerSecond = FrameSamples / FramesPerSecondCounter; FramesPerSecond = FrameSamples / FramesPerSecondCounter;
#else #else
FramesPerSecondCounter += 1000.0f / CTimer::GetTimeStepNonClippedInMilliseconds(); FramesPerSecondCounter += 1000.0f / CTimer::GetTimeStepNonClippedInMilliseconds();