Skip to content

Commit 57b07f4

Browse files
authored
Fix weather flicker 4803 (multitheftauto#4870)
#### Summary Re-apply MTA's blended weather state in `PreWorldProcessHandler` so it runs after the engine's `CWeather::Update` but before `CTimeCycle::CalcColoursForPoint` reads the weather globals for rendering. #### Motivation Fixes multitheftauto#4803. When `setWeatherBlended`/`setTime` are used (e.g. race resource restart/respawn), the sky and ambient lighting flicker for 1-2 frames in fullscreen. The engine's `CWeather::Update` (at `0x53BFC2` in `CGame::Process`) detects a clock wrap when `setTime` jumps the game clock past its internal `InterpolationValue`. It then overwrites `OldWeatherType`/`NewWeatherType` with its own weather-list pick. `CalcColoursForPoint` (at `0x53C0DA`) reads these wrong values and computes incorrect sky/ambient colors for that frame. MTA's `CBlendedWeather::DoPulse` previously only ran in `DoPulses` during `Render2dStuff`, which is after the frame was already rendered with the wrong state. Fullscreen-only because exclusive mode bypasses DWM composition, so every frame including the glitch frames is presented directly. Windowed mode's DWM triple buffering absorbs them. #### Test plan 1. Join a server running the default race resource 2. Set fullscreen (any mode) 3. Use `setWeatherBlended` + `setTime` via script, then restart the race resource to respawn 4. Observe no sky/lighting flicker on respawn #### Checklist * [x] Your code should follow the [coding guidelines](https://wiki.multitheftauto.com/index.php?title=Coding_guidelines). * [x] Smaller pull requests are easier to review. If your pull request is beefy, your pull request should be reviewable commit-by-commit.
1 parent 95e0752 commit 57b07f4

1 file changed

Lines changed: 8 additions & 0 deletions

File tree

Client/mods/deathmatch/logic/CClientGame.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3902,6 +3902,14 @@ void CClientGame::PreRenderSkyHandler()
39023902

39033903
void CClientGame::PreWorldProcessHandler()
39043904
{
3905+
// Fix #4803: Re-apply MTA's weather state before CTimeCycle::CalcColoursForPoint()
3906+
// reads the weather globals for rendering. The engine's CWeather::Update() (0x53BFC2)
3907+
// runs earlier in CGame::Process() and can overwrite OldWeatherType/NewWeatherType
3908+
// when setTime() causes a clock wrap. This hook (at CWorld::Process, 0x53C095) runs
3909+
// after that overwrite but before CalcColoursForPoint (0x53C0DA) consumes the values,
3910+
// ensuring the rendered frame always uses MTA's intended weather.
3911+
if (m_pManager->IsGameLoaded() && m_pBlendedWeather)
3912+
m_pBlendedWeather->DoPulse();
39053913
}
39063914

39073915
void CClientGame::PostWorldProcessHandler()

0 commit comments

Comments
 (0)