You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Fix#4803 building light flicker via pre-CWeather::Update hook
Follow-up to #4870. PR4870 hooks at CWorld::Process (0x53C095) to
re-apply MTA's blended weather before CTimeCycle::CalcColoursForPoint
reads the weather globals at 0x53C0DA — that fixes sky/ambient. But
CWeather::Update itself runs earlier (0x53BFC2), and on the clock-wrap
branch it derives Rain, Foggyness, CloudCoverage, ExtraSunnyness,
SunGlare, HeatHaze, Sandstorm, WetRoads, Wind and Rainbow from a
freshly-picked weather pair. Those globals drive cloud, fog and
night-time building light rendering, so building lights still flickered
after #4870.
Add a HookInstallCall over the call site at 0x53BFC2 and route a new
PreWeatherUpdateHandler through CMultiplayerSA -> CClientGame, calling
CBlendedWeather::DoPulse before CWeather::Update. DoPulse re-applies
Old/New via Set and re-syncs InterpolationValue with the game clock, so
CWeather::Update takes the non-wrap branch and derives every weather
global from MTA's intended pair. The PreWorldProcessHandler hook from
#4870 is kept as a defensive idempotent re-apply.
CBlendedWeather::DoPulse now also calls
CWeather::ResyncInterpolationWithGameClock after Set so the
InterpolationValue used by CalcColoursForPoint matches the clock —
fixes residual flicker on glass/reflective materials that the sky-only
fix in #4870 left behind.
Follow-up to #4870. Move the weather re-apply earlier in `CGame::Process` so the engine's clock-wrap branch in `CWeather::Update` also runs against MTA's intended weather pair.
4
+
5
+
#### Motivation
6
+
7
+
#4870 fixed the sky/ambient flicker by re-applying MTA's weather in `PreWorldProcessHandler` (`0x53C095`), ahead of `CTimeCycle::CalcColoursForPoint` (`0x53C0DA`). Cloud cover, fog and night-time building lights still pop for the same frames, because `CWeather::Update` itself runs earlier (`0x53BFC2`) and on the wrap branch derives `Rain`, `Foggyness`, `CloudCoverage`, `ExtraSunnyness`, `SunGlare`, `HeatHaze`, `Sandstorm`, `WetRoads`, `Wind` and `Rainbow` from its own freshly-picked pair before `PreWorldProcessHandler` gets a chance to fix things.
8
+
9
+
This PR adds a `HookInstallCall` over the `call CWeather::Update` site at `0x53BFC2` and a new `PreWeatherUpdateHandler` that runs `CBlendedWeather::DoPulse` before the engine update. With Old/New/`InterpolationValue` already aligned, `CWeather::Update` takes the non-wrap branch and derives every weather global from MTA's pair. The existing `PreWorldProcessHandler` re-apply from #4870 is kept as an idempotent safety net for the colour-set path.
10
+
11
+
`CBlendedWeather::DoPulse` also calls `CWeather::ResyncInterpolationWithGameClock` after `Set`, so `InterpolationValue` matches the clock — fixes residual flicker on glass/reflective materials that #4870 left behind.
12
+
13
+
#### Test plan
14
+
15
+
1. Join a server running the default race resource
16
+
2. Set fullscreen (any mode)
17
+
3. Use `setWeatherBlended` + `setTime` via script, then restart the race resource to respawn
18
+
4. Observe no sky/lighting flicker on respawn
19
+
5. Repeat at night so building/streetlight glow and cloud cover are visible — they should not pop either
20
+
21
+
#### Checklist
22
+
23
+
*[x] Your code should follow the [coding guidelines](https://wiki.multitheftauto.com/index.php?title=Coding_guidelines).
24
+
*[x] Smaller pull requests are easier to review. If your pull request is beefy, your pull request should be reviewable commit-by-commit.
0 commit comments