@@ -56,39 +56,30 @@ bool CModManager::TriggerCommand(const char* commandName, size_t commandNameLeng
56
56
57
57
void CModManager::DoPulsePreFrame ()
58
58
{
59
- TIMING_GRAPH (" +DoPulsePreFrame" );
60
- CCore::GetSingleton ().GetFPSLimiter ()->OnFrameStart (); // Prepare FPS limiting for this frame
61
-
62
59
if (m_client)
63
60
{
64
61
m_client->PreFrameExecutionHandler ();
65
62
}
66
- TIMING_GRAPH (" -DoPulsePreFrame" );
67
63
}
68
64
69
65
void CModManager::DoPulsePreHUDRender (bool bDidUnminimize, bool bDidRecreateRenderTargets)
70
66
{
71
- TIMING_GRAPH (" +DoPulsePreHUDRender" );
72
67
if (m_client)
73
68
{
74
69
m_client->PreHUDRenderExecutionHandler (bDidUnminimize, bDidRecreateRenderTargets);
75
70
}
76
- TIMING_GRAPH (" -DoPulsePreHUDRender" );
77
71
}
78
72
79
73
void CModManager::DoPulsePostFrame ()
80
74
{
81
- auto handleStateChange = [&]( )
75
+ if (m_state == State::PendingStart )
82
76
{
83
- if (m_state == State::PendingStart)
84
- Start ();
85
- else if (m_state == State::PendingStop)
86
- Stop ();
87
- };
88
-
89
- TIMING_GRAPH (" +DoPulsePostFrame" );
90
-
91
- handleStateChange (); // Handle state changes before pulse
77
+ Start ();
78
+ }
79
+ else if (m_state == State::PendingStop)
80
+ {
81
+ Stop ();
82
+ }
92
83
93
84
if (m_client)
94
85
{
@@ -99,15 +90,20 @@ void CModManager::DoPulsePostFrame()
99
90
CCore::GetSingleton ().GetNetwork ()->DoPulse ();
100
91
}
101
92
102
- CCore::GetSingleton ().DoReliablePulse (); // Do reliable pulse
103
-
104
- handleStateChange (); // Handle state changes after pulse
105
-
106
- // TODO: ENSURE "CModManager::DoPulsePostFrame" IS THE LAST THING BEFORE THE FRAME ENDS
107
- CCore::GetSingleton ().GetFPSLimiter ()->OnFrameEnd (); // Apply FPS limiting
93
+ // Make sure frame rate limit gets applied
94
+ if (m_client != nullptr )
95
+ CCore::GetSingleton ().EnsureFrameRateLimitApplied (); // Catch missed frames
96
+ else
97
+ CCore::GetSingleton ().ApplyFrameRateLimit (); // Limit when not connected
108
98
109
- TIMING_GRAPH (" -DoPulsePostFrame" );
110
- TIMING_GRAPH (" " );
99
+ if (m_state == State::PendingStart)
100
+ {
101
+ Start ();
102
+ }
103
+ else if (m_state == State::PendingStop)
104
+ {
105
+ Stop ();
106
+ }
111
107
}
112
108
113
109
bool CModManager::Load (const char * arguments)
@@ -187,7 +183,7 @@ bool CModManager::TryStart()
187
183
return false ;
188
184
}
189
185
190
- using InitClientFn = CClientBase* (__cdecl*)();
186
+ using InitClientFn = CClientBase*(__cdecl*)();
191
187
InitClientFn initClient = nullptr ;
192
188
if (!SharedUtil::TryGetProcAddress (library, " InitClient" , initClient))
193
189
{
@@ -288,4 +284,3 @@ void CModManager::TryStop()
288
284
CLocalGUI::GetSingleton ().GetMainMenu ()->SetIsIngame (false );
289
285
CLocalGUI::GetSingleton ().GetMainMenu ()->SetVisible (true , false );
290
286
}
291
-
0 commit comments