Skip to content

Commit a41e948

Browse files
committed
Refactored the refactor to match guidelines and one of the last cleanups of code
1 parent 904aae0 commit a41e948

26 files changed

+259
-306
lines changed

Client/cefweb/CWebCore.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -479,11 +479,11 @@ void CWebCore::OnPostScreenshot()
479479
}
480480
}
481481

482-
void CWebCore::OnFPSLimitChange(int iFPS)
482+
void CWebCore::OnFPSLimitChange(std::uint16_t fps)
483483
{
484-
for (auto& pWebView : m_WebViews)
484+
for (auto& webView : m_WebViews)
485485
{
486-
pWebView->GetCefBrowser()->GetHost()->SetWindowlessFrameRate(iFPS);
486+
webView->GetCefBrowser()->GetHost()->SetWindowlessFrameRate(fps);
487487
}
488488
}
489489

Client/cefweb/CWebCore.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ class CWebCore : public CWebCoreInterface
9696
void OnPreScreenshot();
9797
void OnPostScreenshot();
9898

99-
void OnFPSLimitChange(int newFPS);
99+
void OnFPSLimitChange(std::uint16_t fps) override;
100100

101101
bool SetGlobalAudioVolume(float fVolume);
102102

Client/core/CClientVariables.cpp

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -235,12 +235,13 @@ void CClientVariables::ValidateValues()
235235
ClampValue("console_pos", CVector2D(0, 0), CVector2D(uiViewportWidth - 32, uiViewportHeight - 32));
236236
ClampValue("console_size", CVector2D(50, 50), CVector2D(uiViewportWidth - 32, uiViewportHeight - 32));
237237

238-
{ // Special case, 0 or clamped range. Provided by ValidateFPS.
239-
uint uiTemp;
240-
CVARS_GET("fps_limit", uiTemp);
241-
uiTemp = FPSLimiter::ValidateFPS(uiTemp);
242-
CVARS_SET("fps_limit", uiTemp);
243-
}
238+
// CVars need a better API for this (Issue #4427)
239+
int temp;
240+
CVARS_GET("fps_limit", temp);
241+
std::uint16_t fps = static_cast<std::uint16_t>(temp);
242+
FPSLimits::IsValidAndSetValid(fps, fps);
243+
CVARS_SET("fps_limit", fps);
244+
244245

245246
ClampValue("chat_font", 0, 3);
246247
ClampValue("chat_lines", 3, 62);

Client/core/CCommands.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -182,9 +182,9 @@ bool CCommands::Execute(const char* szCommand, const char* szParametersIn, bool
182182
// HACK: Foul dirty hack to force vsync (Rework on #4427)
183183
if (key == "vsync")
184184
{
185-
bool bVSync;
186-
CVARS_GET("vsync", bVSync);
187-
CCore::GetSingleton().GetFPSLimiter()->SetDisplayVSync(bVSync);
185+
bool vSync;
186+
CVARS_GET("vsync", vSync);
187+
CCore::GetSingleton().GetFPSLimiter()->SetDisplayVSync(vSync);
188188
}
189189
}
190190
else

Client/core/CCore.cpp

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1347,7 +1347,7 @@ void CCore::OnModUnload()
13471347
m_pKeyBinds->RemoveAllControlFunctions();
13481348

13491349
// Reset client script frame rate limit
1350-
GetFPSLimiter()->SetClientEnforcedFPS(FPSLimiter::FPS_LIMIT_UNLIMITED);
1350+
GetFPSLimiter()->SetClientEnforcedFPS(FPSLimits::FPS_UNLIMITED);
13511351

13521352
// Clear web whitelist
13531353
if (m_pWebCore)
@@ -1835,12 +1835,9 @@ void CCore::OnGameTimerUpdate()
18351835
// earlier in the callpath (CModManager::DoPulsePreFrame, CModManager::DoPulsePostFrame)
18361836
}
18371837

1838-
void CCore::OnFPSLimitChange(uint32_t uiFPS)
1838+
void CCore::OnFPSLimitChange(std::uint16_t fps)
18391839
{
1840-
// TODO: (pxd) Notify the mod manager maybe? If not remove this comment
1841-
1842-
// Update core's webcore FPS limit
1843-
GetWebCore()->OnFPSLimitChange(uiFPS);
1840+
GetWebCore()->OnFPSLimitChange(fps); // Update core's webcore FPS limit
18441841
}
18451842

18461843
//

Client/core/CCore.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ class CCore : public CCoreInterface, public CSingleton<CCore>
108108
CTrayIconInterface* GetTrayIcon() { return m_pTrayIcon; };
109109
std::shared_ptr<CDiscordInterface> GetDiscord();
110110
CSteamClient* GetSteamClient() { return m_steamClient.get(); }
111-
FPSLimiter::FPSLimiterInterface* GetFPSLimiter() { return m_pFPSLimiter.get(); }
111+
FPSLimiter::FPSLimiterInterface* GetFPSLimiter() const noexcept { return m_pFPSLimiter.get(); }
112112

113113
void SaveConfig(bool bWaitUntilFinished = false);
114114

@@ -223,7 +223,7 @@ class CCore : public CCoreInterface, public CSingleton<CCore>
223223
void InitiateDataFilesFix() { m_pLocalGUI->InitiateDataFilesFix(); }
224224

225225
// FPS Limiter
226-
void OnFPSLimitChange(uint32_t uiFPS); // Called when FPS limit changes
226+
void OnFPSLimitChange(std::uint16_t fps);
227227

228228
void DoReliablePulse();
229229

Client/core/CModManager.cpp

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -79,17 +79,10 @@ void CModManager::DoPulsePostFrame()
7979
{
8080
auto handleStateChange = [&]()
8181
{
82-
switch (m_state)
83-
{
84-
case State::PendingStart:
85-
Start();
86-
break;
87-
case State::PendingStop:
88-
Stop();
89-
break;
90-
default:
91-
break;
92-
}
82+
if (m_state == State::PendingStart)
83+
Start();
84+
else if (m_state == State::PendingStop)
85+
Stop();
9386
};
9487

9588
TIMING_GRAPH("+DoPulsePostFrame");

0 commit comments

Comments
 (0)