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.
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:
AmnesiaTheDarkDescent/amnesia/src/game/LuxInventory.cpp
Line 749 in acc95cd
AmnesiaTheDarkDescent/amnesia/src/game/LuxInventory.cpp
Line 981 in acc95cd
AmnesiaTheDarkDescent/amnesia/src/game/LuxJournal.cpp
Line 486 in acc95cd
AmnesiaTheDarkDescent/amnesia/src/game/LuxJournal.cpp
Line 612 in acc95cd
All of these calls to
DrawFlashandUpdatenever check if the flash is active. Normally,mfAlphais 0 if the flash is inactive, so nothing happens. However,cLuxEffect_SanityGainFlashonly initializesmfAlphaandmlStepinStart, so they may be garbage initially. The flash appears ifmfAlphais initially a value that can be interpreted as a float greater than 0 but less than 1, as well asmlStepbeing an integer that isn't 0, 1, or 2 (preventingUpdatefrom changingmfAlpha).Fix:
This prevents the functions from being called at all if the flash is inactive, which I think is the best option.