summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--src/audio/AudioManager.cpp15
-rw-r--r--src/audio/AudioManager.h4
-rw-r--r--src/audio/MusicManager.cpp4
-rw-r--r--src/core/Timer.cpp10
-rw-r--r--src/core/Timer.h2
-rw-r--r--src/render/Hud.cpp30
6 files changed, 34 insertions, 31 deletions
diff --git a/src/audio/AudioManager.cpp b/src/audio/AudioManager.cpp
index 69126c23..c49ce552 100644
--- a/src/audio/AudioManager.cpp
+++ b/src/audio/AudioManager.cpp
@@ -41,11 +41,6 @@ cAudioManager::cAudioManager()
m_bFifthFrameFlag = FALSE;
m_bTimerJustReset = FALSE;
m_nTimer = 0;
-
-#ifdef FIX_BUGS
- m_LogicalFrameCounter = 0;
- m_bLogicalFrameUpdate = FALSE;
-#endif
}
cAudioManager::~cAudioManager()
@@ -105,12 +100,6 @@ cAudioManager::Terminate()
void
cAudioManager::Service()
{
-#ifdef FIX_BUGS
- m_bLogicalFrameUpdate = m_LogicalFrameCounter != CTimer::GetLogicalFrameCounter();
- if(m_bLogicalFrameUpdate)
- m_LogicalFrameCounter = CTimer::GetLogicalFrameCounter();
-#endif
-
GenerateIntegerRandomNumberTable();
if (m_bTimerJustReset) {
ResetAudioLogicTimers(m_nTimer);
@@ -435,7 +424,7 @@ void
cAudioManager::ServiceSoundEffects()
{
#ifdef FIX_BUGS
- if(m_bLogicalFrameUpdate)
+ if(CTimer::GetLogicalFramesPassed() != 0)
#endif
m_bFifthFrameFlag = (m_FrameCounter++ % 5) == 0;
if (m_nUserPause && !m_nPreviousUserPause) {
@@ -741,7 +730,7 @@ cAudioManager::AddReleasingSounds()
sample.m_nVolume -= sample.m_nVolumeChange;
}
#ifdef FIX_BUGS
- if(m_bLogicalFrameUpdate)
+ if(CTimer::GetLogicalFramesPassed() != 0)
#endif
--sample.m_nReleasingVolumeDivider;
if (m_bFifthFrameFlag) {
diff --git a/src/audio/AudioManager.h b/src/audio/AudioManager.h
index dcd6c7c4..70302745 100644
--- a/src/audio/AudioManager.h
+++ b/src/audio/AudioManager.h
@@ -223,10 +223,6 @@ public:
uint8 m_nUserPause;
uint8 m_nPreviousUserPause;
uint32 m_FrameCounter;
-#ifdef FIX_BUGS
- uint32 m_LogicalFrameCounter;
- bool8 m_bLogicalFrameUpdate;
-#endif
cAudioManager();
~cAudioManager();
diff --git a/src/audio/MusicManager.cpp b/src/audio/MusicManager.cpp
index 4eaa37d5..957fce55 100644
--- a/src/audio/MusicManager.cpp
+++ b/src/audio/MusicManager.cpp
@@ -195,7 +195,11 @@ cMusicManager::DisplayRadioStationName()
cDisplay = 60;
} else {
if(cDisplay == 0) return;
+#ifdef FIX_BUGS
+ cDisplay -= CTimer::GetLogicalFramesPassed();
+#else
cDisplay--;
+#endif
}
CFont::SetJustifyOff();
diff --git a/src/core/Timer.cpp b/src/core/Timer.cpp
index 5c7d012e..5771274a 100644
--- a/src/core/Timer.cpp
+++ b/src/core/Timer.cpp
@@ -18,6 +18,7 @@ bool CTimer::m_UserPause;
bool CTimer::m_CodePause;
#ifdef FIX_BUGS
uint32 CTimer::m_LogicalFrameCounter;
+uint32 CTimer::m_LogicalFramesPassed;
#endif
uint32 _nCyclesPerMS = 1;
@@ -54,6 +55,7 @@ void CTimer::Initialise(void)
m_snTimeInMilliseconds = 1;
#ifdef FIX_BUGS
m_LogicalFrameCounter = 0;
+ m_LogicalFramesPassed = 0;
#endif
#ifdef _WIN32
@@ -109,12 +111,14 @@ void CTimer::Update(void)
frameTime = updInCyclesScaled / (double)_nCyclesPerMS;
#ifdef FIX_BUGS
+ m_LogicalFramesPassed = 0;
static double frameTimeLogical = 0.0;
frameTimeLogical += ((double)updInCycles / (double)_nCyclesPerMS);
while (frameTimeLogical >= 1000.0 / 30.0) {
frameTimeLogical -= 1000.0 / 30.0;
- m_LogicalFrameCounter++;
+ m_LogicalFramesPassed++;
}
+ m_LogicalFrameCounter += m_LogicalFramesPassed;
#endif
m_snTimeInMillisecondsPauseMode = m_snTimeInMillisecondsPauseMode + frameTime;
@@ -142,12 +146,14 @@ void CTimer::Update(void)
frameTime = (double)updInMs * ms_fTimeScale;
#ifdef FIX_BUGS
+ m_LogicalFramesPassed = 0;
static double frameTimeLogical = 0.0;
frameTimeLogical += (double)updInMs;
while(frameTimeLogical >= 1000.0 / 30.0) {
frameTimeLogical -= 1000.0 / 30.0;
- m_LogicalFrameCounter++;
+ m_LogicalFramesPassed++;
}
+ m_LogicalFrameCounter += m_LogicalFramesPassed;
#endif
oldPcTimer = timer;
diff --git a/src/core/Timer.h b/src/core/Timer.h
index ebde1747..7b68303a 100644
--- a/src/core/Timer.h
+++ b/src/core/Timer.h
@@ -13,6 +13,7 @@ class CTimer
static float ms_fTimeStepNonClipped;
#ifdef FIX_BUGS
static uint32 m_LogicalFrameCounter;
+ static uint32 m_LogicalFramesPassed;
#endif
public:
static bool m_UserPause;
@@ -65,6 +66,7 @@ public:
static float GetDefaultTimeStep(void) { return 50.0f / 30.0f; }
static float GetTimeStepFix(void) { return GetTimeStep() / GetDefaultTimeStep(); }
static uint32 GetLogicalFrameCounter(void) { return m_LogicalFrameCounter; }
+ static uint32 GetLogicalFramesPassed(void) { return m_LogicalFramesPassed; }
#endif
};
diff --git a/src/render/Hud.cpp b/src/render/Hud.cpp
index 4991e024..bba8c525 100644
--- a/src/render/Hud.cpp
+++ b/src/render/Hud.cpp
@@ -75,6 +75,12 @@
#define SCALE_AND_CENTER_X_FIX(a) (a)
#endif
+#ifdef FIX_BUGS
+#define FRAMECOUNTER CTimer::GetLogicalFrameCounter()
+#else
+#define FRAMECOUNTER CTimer::GetFrameCounter()
+#endif
+
// Game has colors inlined in code.
// For easier modification we collect them here:
CRGBA MONEY_COLOR(89, 115, 150, 255);
@@ -577,12 +583,12 @@ void CHud::Draw()
CFont::SetPropOff();
CFont::SetFontStyle(FONT_HEADING);
- if (m_ItemToFlash == ITEM_HEALTH && CTimer::GetFrameCounter() & 8
+ if (m_ItemToFlash == ITEM_HEALTH && FRAMECOUNTER & 8
|| m_ItemToFlash != ITEM_HEALTH
|| FindPlayerPed()->m_fHealth < 10
- && CTimer::GetFrameCounter() & 8) {
+ && FRAMECOUNTER & 8) {
if (FindPlayerPed()->m_fHealth >= 10
- || FindPlayerPed()->m_fHealth < 10 && CTimer::GetFrameCounter() & 8) {
+ || FindPlayerPed()->m_fHealth < 10 && FRAMECOUNTER & 8) {
AsciiToUnicode("{", sPrintIcon);
#ifdef FIX_BUGS
@@ -594,14 +600,14 @@ void CHud::Draw()
CFont::SetColor(CRGBA(0, 0, 0, 255));
CFont::PrintString(SCREEN_SCALE_FROM_RIGHT(HEALTH_X) + SCREEN_SCALE_X_FIX(2.0f), SCREEN_SCALE_Y(65.0f) + SCREEN_SCALE_Y_FIX(2.0f), sPrint);
- if (!CWorld::Players[CWorld::PlayerInFocus].m_nTimeLastHealthLoss || CTimer::GetTimeInMilliseconds() > CWorld::Players[CWorld::PlayerInFocus].m_nTimeLastHealthLoss + 2000 || CTimer::GetFrameCounter() & 4)
+ if (!CWorld::Players[CWorld::PlayerInFocus].m_nTimeLastHealthLoss || CTimer::GetTimeInMilliseconds() > CWorld::Players[CWorld::PlayerInFocus].m_nTimeLastHealthLoss + 2000 || FRAMECOUNTER & 4)
CFont::PrintString(SCREEN_SCALE_FROM_RIGHT(HEALTH_X) + SCREEN_SCALE_X_FIX(2.0f) - SCREEN_SCALE_X(56.0f) + SCREEN_SCALE_X(2.0f), SCREEN_SCALE_Y(65.0f) + SCREEN_SCALE_Y_FIX(2.0f), sPrintIcon);
CFont::SetColor(HEALTH_COLOR);
CFont::PrintString(SCREEN_SCALE_FROM_RIGHT(HEALTH_X), SCREEN_SCALE_Y(65.0f), sPrint);
- if (!CWorld::Players[CWorld::PlayerInFocus].m_nTimeLastHealthLoss || CTimer::GetTimeInMilliseconds() > CWorld::Players[CWorld::PlayerInFocus].m_nTimeLastHealthLoss + 2000 || CTimer::GetFrameCounter() & 4)
+ if (!CWorld::Players[CWorld::PlayerInFocus].m_nTimeLastHealthLoss || CTimer::GetTimeInMilliseconds() > CWorld::Players[CWorld::PlayerInFocus].m_nTimeLastHealthLoss + 2000 || FRAMECOUNTER & 4)
CFont::PrintString(SCREEN_SCALE_FROM_RIGHT(HEALTH_X) + SCREEN_SCALE_X_FIX(2.0f) - SCREEN_SCALE_X(56.0f), SCREEN_SCALE_Y(65.0f), sPrintIcon);
}
}
@@ -609,7 +615,7 @@ void CHud::Draw()
/*
DrawArmour
*/
- if (m_ItemToFlash == ITEM_ARMOUR && CTimer::GetFrameCounter() & 8 || m_ItemToFlash != ITEM_ARMOUR) {
+ if (m_ItemToFlash == ITEM_ARMOUR && FRAMECOUNTER & 8 || m_ItemToFlash != ITEM_ARMOUR) {
CFont::SetScale(SCREEN_SCALE_X(0.8f), SCREEN_SCALE_Y(1.35f));
if (FindPlayerPed()->m_fArmour > 1.0f) {
AsciiToUnicode("[", sPrintIcon);
@@ -623,14 +629,14 @@ void CHud::Draw()
CFont::SetColor(CRGBA(0, 0, 0, 255));
CFont::PrintString(SCREEN_SCALE_FROM_RIGHT(182.0f) + SCREEN_SCALE_X_FIX(2.0f), SCREEN_SCALE_Y(65.0f) + SCREEN_SCALE_Y_FIX(2.0f), sPrint);
- if (!CWorld::Players[CWorld::PlayerInFocus].m_nTimeLastArmourLoss || CTimer::GetTimeInMilliseconds() > CWorld::Players[CWorld::PlayerInFocus].m_nTimeLastArmourLoss + 2000 || CTimer::GetFrameCounter() & 4)
+ if (!CWorld::Players[CWorld::PlayerInFocus].m_nTimeLastArmourLoss || CTimer::GetTimeInMilliseconds() > CWorld::Players[CWorld::PlayerInFocus].m_nTimeLastArmourLoss + 2000 || FRAMECOUNTER & 4)
CFont::PrintString(SCREEN_SCALE_FROM_RIGHT(182.0f) + SCREEN_SCALE_X_FIX(2.0f) - SCREEN_SCALE_X(54.0f) + SCREEN_SCALE_X(2.0f), SCREEN_SCALE_Y(65.0f) + SCREEN_SCALE_Y_FIX(2.0f), sPrintIcon);
CFont::SetColor(ARMOUR_COLOR);
CFont::PrintString(SCREEN_SCALE_FROM_RIGHT(182.0f), SCREEN_SCALE_Y(65.0f), sPrint);
- if (!CWorld::Players[CWorld::PlayerInFocus].m_nTimeLastArmourLoss || CTimer::GetTimeInMilliseconds() > CWorld::Players[CWorld::PlayerInFocus].m_nTimeLastArmourLoss + 2000 || CTimer::GetFrameCounter() & 1) {
+ if (!CWorld::Players[CWorld::PlayerInFocus].m_nTimeLastArmourLoss || CTimer::GetTimeInMilliseconds() > CWorld::Players[CWorld::PlayerInFocus].m_nTimeLastArmourLoss + 2000 || FRAMECOUNTER & 1) {
CFont::PrintString(SCREEN_SCALE_FROM_RIGHT(182.0f) - SCREEN_SCALE_X(54.0f) + SCREEN_SCALE_X(2.0f), SCREEN_SCALE_Y(65.0f), sPrintIcon);
}
}
@@ -657,7 +663,7 @@ void CHud::Draw()
if (FindPlayerPed()->m_pWanted->GetWantedLevel() > i
&& (CTimer::GetTimeInMilliseconds() > FindPlayerPed()->m_pWanted->m_nLastWantedLevelChange
- + 2000 || CTimer::GetFrameCounter() & 4)) {
+ + 2000 || FRAMECOUNTER & 4)) {
CFont::SetColor(WANTED_COLOR);
CFont::PrintString(fStarsX, SCREEN_SCALE_Y(87.0f), sPrintIcon);
@@ -904,7 +910,7 @@ void CHud::Draw()
TimerFlashTimer = 0;
}
- if (CTimer::GetFrameCounter() & 4 || !TimerFlashTimer) {
+ if (FRAMECOUNTER & 4 || !TimerFlashTimer) {
AsciiToUnicode(CUserDisplay::OnscnTimer.m_sEntries[0].m_bTimerBuffer, sTimer);
CFont::SetPropOn();
CFont::SetBackgroundOff();
@@ -941,7 +947,7 @@ void CHud::Draw()
CounterFlashTimer = 0;
}
- if (CTimer::GetFrameCounter() & 4 || !CounterFlashTimer) {
+ if (FRAMECOUNTER & 4 || !CounterFlashTimer) {
if (CUserDisplay::OnscnTimer.m_sEntries[0].m_nType == COUNTER_DISPLAY_NUMBER) {
AsciiToUnicode(CUserDisplay::OnscnTimer.m_sEntries[0].m_bCounterBuffer, sTimer);
CFont::SetPropOn();
@@ -1053,7 +1059,7 @@ void CHud::Draw()
/*
DrawRadar
*/
- if (m_ItemToFlash == ITEM_RADAR && CTimer::GetFrameCounter() & 8 || m_ItemToFlash != ITEM_RADAR) {
+ if (m_ItemToFlash == ITEM_RADAR && FRAMECOUNTER & 8 || m_ItemToFlash != ITEM_RADAR) {
CRadar::DrawMap();
CRect rect(0.0f, 0.0f, SCREEN_SCALE_X(RADAR_WIDTH), SCREEN_SCALE_Y(RADAR_HEIGHT));
rect.Translate(SCREEN_SCALE_X_FIX(RADAR_LEFT), SCREEN_SCALE_FROM_BOTTOM(RADAR_BOTTOM + RADAR_HEIGHT));