Fix redone + add hud fix

This commit is contained in:
Sergeanur 2021-05-29 11:57:51 +03:00
parent cacec36dd1
commit f741101e44
6 changed files with 34 additions and 31 deletions

View File

@ -41,11 +41,6 @@ cAudioManager::cAudioManager()
m_bFifthFrameFlag = FALSE; m_bFifthFrameFlag = FALSE;
m_bTimerJustReset = FALSE; m_bTimerJustReset = FALSE;
m_nTimer = 0; m_nTimer = 0;
#ifdef FIX_BUGS
m_LogicalFrameCounter = 0;
m_bLogicalFrameUpdate = FALSE;
#endif
} }
cAudioManager::~cAudioManager() cAudioManager::~cAudioManager()
@ -105,12 +100,6 @@ cAudioManager::Terminate()
void void
cAudioManager::Service() cAudioManager::Service()
{ {
#ifdef FIX_BUGS
m_bLogicalFrameUpdate = m_LogicalFrameCounter != CTimer::GetLogicalFrameCounter();
if(m_bLogicalFrameUpdate)
m_LogicalFrameCounter = CTimer::GetLogicalFrameCounter();
#endif
GenerateIntegerRandomNumberTable(); GenerateIntegerRandomNumberTable();
if (m_bTimerJustReset) { if (m_bTimerJustReset) {
ResetAudioLogicTimers(m_nTimer); ResetAudioLogicTimers(m_nTimer);
@ -435,7 +424,7 @@ void
cAudioManager::ServiceSoundEffects() cAudioManager::ServiceSoundEffects()
{ {
#ifdef FIX_BUGS #ifdef FIX_BUGS
if(m_bLogicalFrameUpdate) if(CTimer::GetLogicalFramesPassed() != 0)
#endif #endif
m_bFifthFrameFlag = (m_FrameCounter++ % 5) == 0; m_bFifthFrameFlag = (m_FrameCounter++ % 5) == 0;
if (m_nUserPause && !m_nPreviousUserPause) { if (m_nUserPause && !m_nPreviousUserPause) {
@ -741,7 +730,7 @@ cAudioManager::AddReleasingSounds()
sample.m_nVolume -= sample.m_nVolumeChange; sample.m_nVolume -= sample.m_nVolumeChange;
} }
#ifdef FIX_BUGS #ifdef FIX_BUGS
if(m_bLogicalFrameUpdate) if(CTimer::GetLogicalFramesPassed() != 0)
#endif #endif
--sample.m_nReleasingVolumeDivider; --sample.m_nReleasingVolumeDivider;
if (m_bFifthFrameFlag) { if (m_bFifthFrameFlag) {

View File

@ -223,10 +223,6 @@ public:
uint8 m_nUserPause; uint8 m_nUserPause;
uint8 m_nPreviousUserPause; uint8 m_nPreviousUserPause;
uint32 m_FrameCounter; uint32 m_FrameCounter;
#ifdef FIX_BUGS
uint32 m_LogicalFrameCounter;
bool8 m_bLogicalFrameUpdate;
#endif
cAudioManager(); cAudioManager();
~cAudioManager(); ~cAudioManager();

View File

@ -195,7 +195,11 @@ cMusicManager::DisplayRadioStationName()
cDisplay = 60; cDisplay = 60;
} 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

@ -18,6 +18,7 @@ bool CTimer::m_UserPause;
bool CTimer::m_CodePause; bool CTimer::m_CodePause;
#ifdef FIX_BUGS #ifdef FIX_BUGS
uint32 CTimer::m_LogicalFrameCounter; uint32 CTimer::m_LogicalFrameCounter;
uint32 CTimer::m_LogicalFramesPassed;
#endif #endif
uint32 _nCyclesPerMS = 1; uint32 _nCyclesPerMS = 1;
@ -54,6 +55,7 @@ void CTimer::Initialise(void)
m_snTimeInMilliseconds = 1; m_snTimeInMilliseconds = 1;
#ifdef FIX_BUGS #ifdef FIX_BUGS
m_LogicalFrameCounter = 0; m_LogicalFrameCounter = 0;
m_LogicalFramesPassed = 0;
#endif #endif
#ifdef _WIN32 #ifdef _WIN32
@ -109,12 +111,14 @@ void CTimer::Update(void)
frameTime = updInCyclesScaled / (double)_nCyclesPerMS; frameTime = updInCyclesScaled / (double)_nCyclesPerMS;
#ifdef FIX_BUGS #ifdef FIX_BUGS
m_LogicalFramesPassed = 0;
static double frameTimeLogical = 0.0; static double frameTimeLogical = 0.0;
frameTimeLogical += ((double)updInCycles / (double)_nCyclesPerMS); frameTimeLogical += ((double)updInCycles / (double)_nCyclesPerMS);
while (frameTimeLogical >= 1000.0 / 30.0) { while (frameTimeLogical >= 1000.0 / 30.0) {
frameTimeLogical -= 1000.0 / 30.0; frameTimeLogical -= 1000.0 / 30.0;
m_LogicalFrameCounter++; m_LogicalFramesPassed++;
} }
m_LogicalFrameCounter += m_LogicalFramesPassed;
#endif #endif
m_snTimeInMillisecondsPauseMode = m_snTimeInMillisecondsPauseMode + frameTime; m_snTimeInMillisecondsPauseMode = m_snTimeInMillisecondsPauseMode + frameTime;
@ -142,12 +146,14 @@ void CTimer::Update(void)
frameTime = (double)updInMs * ms_fTimeScale; frameTime = (double)updInMs * ms_fTimeScale;
#ifdef FIX_BUGS #ifdef FIX_BUGS
m_LogicalFramesPassed = 0;
static double frameTimeLogical = 0.0; static double frameTimeLogical = 0.0;
frameTimeLogical += (double)updInMs; frameTimeLogical += (double)updInMs;
while(frameTimeLogical >= 1000.0 / 30.0) { while(frameTimeLogical >= 1000.0 / 30.0) {
frameTimeLogical -= 1000.0 / 30.0; frameTimeLogical -= 1000.0 / 30.0;
m_LogicalFrameCounter++; m_LogicalFramesPassed++;
} }
m_LogicalFrameCounter += m_LogicalFramesPassed;
#endif #endif
oldPcTimer = timer; oldPcTimer = timer;

View File

@ -13,6 +13,7 @@ class CTimer
static float ms_fTimeStepNonClipped; static float ms_fTimeStepNonClipped;
#ifdef FIX_BUGS #ifdef FIX_BUGS
static uint32 m_LogicalFrameCounter; static uint32 m_LogicalFrameCounter;
static uint32 m_LogicalFramesPassed;
#endif #endif
public: public:
static bool m_UserPause; static bool m_UserPause;
@ -65,6 +66,7 @@ public:
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 GetLogicalFrameCounter(void) { return m_LogicalFrameCounter; }
static uint32 GetLogicalFramesPassed(void) { return m_LogicalFramesPassed; }
#endif #endif
}; };

View File

@ -75,6 +75,12 @@
#define SCALE_AND_CENTER_X_FIX(a) (a) #define SCALE_AND_CENTER_X_FIX(a) (a)
#endif #endif
#ifdef FIX_BUGS
#define FRAMECOUNTER CTimer::GetLogicalFrameCounter()
#else
#define FRAMECOUNTER CTimer::GetFrameCounter()
#endif
// Game has colors inlined in code. // Game has colors inlined in code.
// For easier modification we collect them here: // For easier modification we collect them here:
CRGBA MONEY_COLOR(89, 115, 150, 255); CRGBA MONEY_COLOR(89, 115, 150, 255);
@ -577,12 +583,12 @@ void CHud::Draw()
CFont::SetPropOff(); CFont::SetPropOff();
CFont::SetFontStyle(FONT_HEADING); CFont::SetFontStyle(FONT_HEADING);
if (m_ItemToFlash == ITEM_HEALTH && CTimer::GetFrameCounter() & 8 if (m_ItemToFlash == ITEM_HEALTH && FRAMECOUNTER & 8
|| m_ItemToFlash != ITEM_HEALTH || m_ItemToFlash != ITEM_HEALTH
|| FindPlayerPed()->m_fHealth < 10 || FindPlayerPed()->m_fHealth < 10
&& CTimer::GetFrameCounter() & 8) { && FRAMECOUNTER & 8) {
if (FindPlayerPed()->m_fHealth >= 10 if (FindPlayerPed()->m_fHealth >= 10
|| FindPlayerPed()->m_fHealth < 10 && CTimer::GetFrameCounter() & 8) { || FindPlayerPed()->m_fHealth < 10 && FRAMECOUNTER & 8) {
AsciiToUnicode("{", sPrintIcon); AsciiToUnicode("{", sPrintIcon);
#ifdef FIX_BUGS #ifdef FIX_BUGS
@ -594,14 +600,14 @@ void CHud::Draw()
CFont::SetColor(CRGBA(0, 0, 0, 255)); 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); 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::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::SetColor(HEALTH_COLOR);
CFont::PrintString(SCREEN_SCALE_FROM_RIGHT(HEALTH_X), SCREEN_SCALE_Y(65.0f), sPrint); 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); 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 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)); CFont::SetScale(SCREEN_SCALE_X(0.8f), SCREEN_SCALE_Y(1.35f));
if (FindPlayerPed()->m_fArmour > 1.0f) { if (FindPlayerPed()->m_fArmour > 1.0f) {
AsciiToUnicode("[", sPrintIcon); AsciiToUnicode("[", sPrintIcon);
@ -623,14 +629,14 @@ void CHud::Draw()
CFont::SetColor(CRGBA(0, 0, 0, 255)); 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); 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::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::SetColor(ARMOUR_COLOR);
CFont::PrintString(SCREEN_SCALE_FROM_RIGHT(182.0f), SCREEN_SCALE_Y(65.0f), sPrint); 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); 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 if (FindPlayerPed()->m_pWanted->GetWantedLevel() > i
&& (CTimer::GetTimeInMilliseconds() > FindPlayerPed()->m_pWanted->m_nLastWantedLevelChange && (CTimer::GetTimeInMilliseconds() > FindPlayerPed()->m_pWanted->m_nLastWantedLevelChange
+ 2000 || CTimer::GetFrameCounter() & 4)) { + 2000 || FRAMECOUNTER & 4)) {
CFont::SetColor(WANTED_COLOR); CFont::SetColor(WANTED_COLOR);
CFont::PrintString(fStarsX, SCREEN_SCALE_Y(87.0f), sPrintIcon); CFont::PrintString(fStarsX, SCREEN_SCALE_Y(87.0f), sPrintIcon);
@ -904,7 +910,7 @@ void CHud::Draw()
TimerFlashTimer = 0; TimerFlashTimer = 0;
} }
if (CTimer::GetFrameCounter() & 4 || !TimerFlashTimer) { if (FRAMECOUNTER & 4 || !TimerFlashTimer) {
AsciiToUnicode(CUserDisplay::OnscnTimer.m_sEntries[0].m_bTimerBuffer, sTimer); AsciiToUnicode(CUserDisplay::OnscnTimer.m_sEntries[0].m_bTimerBuffer, sTimer);
CFont::SetPropOn(); CFont::SetPropOn();
CFont::SetBackgroundOff(); CFont::SetBackgroundOff();
@ -941,7 +947,7 @@ void CHud::Draw()
CounterFlashTimer = 0; CounterFlashTimer = 0;
} }
if (CTimer::GetFrameCounter() & 4 || !CounterFlashTimer) { if (FRAMECOUNTER & 4 || !CounterFlashTimer) {
if (CUserDisplay::OnscnTimer.m_sEntries[0].m_nType == COUNTER_DISPLAY_NUMBER) { if (CUserDisplay::OnscnTimer.m_sEntries[0].m_nType == COUNTER_DISPLAY_NUMBER) {
AsciiToUnicode(CUserDisplay::OnscnTimer.m_sEntries[0].m_bCounterBuffer, sTimer); AsciiToUnicode(CUserDisplay::OnscnTimer.m_sEntries[0].m_bCounterBuffer, sTimer);
CFont::SetPropOn(); CFont::SetPropOn();
@ -1053,7 +1059,7 @@ void CHud::Draw()
/* /*
DrawRadar 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(); CRadar::DrawMap();
CRect rect(0.0f, 0.0f, SCREEN_SCALE_X(RADAR_WIDTH), SCREEN_SCALE_Y(RADAR_HEIGHT)); 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)); rect.Translate(SCREEN_SCALE_X_FIX(RADAR_LEFT), SCREEN_SCALE_FROM_BOTTOM(RADAR_BOTTOM + RADAR_HEIGHT));