Skip to content

Persistent sanity gain flash in inventory and journal #26

Description

@BoxFigs

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions