-
Notifications
You must be signed in to change notification settings - Fork 372
Description
Sometimes when starting a new game or loading a save, the sanity gain flash will appear over the inventory and journal, stuck in place until the player gains sanity. The flash doesn't change, just staying as a static overlay.
Seen prominently in this video of a custom story: https://youtu.be/DAJ8jY0J0yU&t=1237 (no sanity is gained so the effect stays for the entire video)
Caused by:
gpBase->mpEffectHandler->GetSanityGainFlash()->Update(afTimeStep); |
gpBase->mpEffectHandler->GetSanityGainFlash()->DrawFlash(mpGuiSet, afFrameTime); |
gpBase->mpEffectHandler->GetSanityGainFlash()->Update(afTimeStep); |
gpBase->mpEffectHandler->GetSanityGainFlash()->DrawFlash(mpGuiSet, afFrameTime); |
All of these calls to DrawFlash
and Update
never check if the flash is active. Normally, mfAlpha
is 0 if the flash is inactive, so nothing happens. However, cLuxEffect_SanityGainFlash
only initializes mfAlpha
and mlStep
in Start
, so they may be garbage initially. The flash appears if mfAlpha
is initially a value that can be interpreted as a float greater than 0 but less than 1, as well as mlStep
being an integer that isn't 0, 1, or 2 (preventing Update
from changing mfAlpha
).
Fix:
cLuxEffect_SanityGainFlash *pSanityGainFlash = gpBase->mpEffectHandler->GetSanityGainFlash();
if (pSantityGainFlash->IsActive())
pSantityGainFlash->Update(afTimeStep);
cLuxEffect_SanityGainFlash *pSanityGainFlash = gpBase->mpEffectHandler->GetSanityGainFlash();
if (pSantityGainFlash->IsActive())
pSantityGainFlash->DrawFlash(mpGuiSet, afFrameTime);
This prevents the functions from being called at all if the flash is inactive, which I think is the best option.