Skip to content

Commit 477248c

Browse files
committed
Fix vehicle corona/shadow flicker on fogless to foggy weather blend (#4803)
ResyncInterpolationWithGameClock snapped CWeather::InterpolationValue to minute/60, dropping the seconds component. CTimeCycle::CalcColoursForPoint then blended m_CurrentColours per game-minute instead of per frame, so m_fSpriteBrightness (vehicle coronas) and m_wShadowStrength (vehicle shadows) ticked visibly when the game clock runs fast. Match the value CWeather::Update derives at 0x72B897 (seconds/3600 + minutes/60) so the wrap-suppression still holds and m_CurrentColours interpolates smoothly each frame.
1 parent bb7e811 commit 477248c

2 files changed

Lines changed: 11 additions & 3 deletions

File tree

Client/game_sa/CWeatherSA.cpp

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,13 +30,20 @@ void CWeatherSA::ResyncInterpolationWithGameClock(unsigned char primary, unsigne
3030
// CWeather::InterpolationValue — see plugin_sa CWeather.cpp (0xC8130C)
3131
constexpr DWORD VAR_InterpolationValue = 0xC8130C;
3232
constexpr DWORD VAR_TimeMinutes = 0xB70152;
33+
constexpr DWORD VAR_TimeSeconds = 0xB70150;
3334

3435
if (primary == secondary)
3536
MemPutFast<float>(VAR_InterpolationValue, 0.0f);
3637
else
3738
{
39+
// Match the value CWeather::Update derives at 0x72B897:
40+
// v0 = (seconds / 60 + minutes) / 60
41+
// Snapping to minutes only would drop seconds and make CTimeCycle::CalcColoursForPoint
42+
// step m_CurrentColours per game-minute, which surfaces as flicker on vehicle coronas
43+
// (m_fSpriteBrightness) and shadows (m_wShadowStrength) when the clock runs fast.
3844
const auto ucMinute = *reinterpret_cast<unsigned char*>(VAR_TimeMinutes);
39-
const float fInterp = std::min(1.f, static_cast<float>(ucMinute) / 60.f);
45+
const auto ucSecond = *reinterpret_cast<unsigned char*>(VAR_TimeSeconds);
46+
const float fInterp = std::min(1.f, static_cast<float>(ucMinute) / 60.f + static_cast<float>(ucSecond) / 3600.f);
4047
MemPutFast<float>(VAR_InterpolationValue, fInterp);
4148
}
4249
}

Client/mods/deathmatch/logic/CBlendedWeather.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,8 +58,9 @@ void CBlendedWeather::DoPulse()
5858

5959
m_pWeather->Set(ucPrimary, ucSecondary);
6060
// CWeather::Update (before this pulse) advances InterpolationValue for its own Old/New pair.
61-
// After we overwrite Old/New with MTA's state, keep the blend weight aligned with the game
62-
// clock so reflective/translucent materials (e.g. glass windows) match the sky (#4803).
61+
// After we overwrite Old/New with MTA's state, mirror the value CWeather::Update would derive
62+
// (seconds/3600 + minutes/60) so CTimeCycle::CalcColoursForPoint blends m_CurrentColours
63+
// smoothly per frame instead of stepping per game-minute (#4803).
6364
m_pWeather->ResyncInterpolationWithGameClock(ucPrimary, ucSecondary);
6465
}
6566

0 commit comments

Comments
 (0)