Bug with fader window

In win32_handmade.cpp we have following code:
1
2
    win32_fader Fader;
    InitFader(&Fader, Instance);

InitFader function only tries to set Fader->Window member, but always leaves Fader->State and Fader->Alpha uninitialized. It actually can also skip assignment to Fader->Window if RegisterClassA fails (unlikely).

Not initializing Fader->State member, will make assertion later in UpdateFade to fail:
1
2
3
4
5
6
7
8
switch(Fader->State)
{
    ...
    default:
    {
        Assert(!"Unrecognized fader state!");
    } break;    
}

Because Fader->State will contain garbage value (whatever is on the stack in Fader structure) and no case will match it.

Edited by Mārtiņš Možeiko on