ValveSoftware / source-sdk-2013

The 2013 edition of the Source SDK
https://developer.valvesoftware.com/wiki/SDK2013_GettingStarted
Other
3.77k stars 2k forks source link

EnvFade entity input missing FFADE_PURGE flag #479

Open Li-Zero opened 5 years ago

Li-Zero commented 5 years ago

I tried making vscripts for map and saw that there's problem with env_fade entity. You can't do fade in for one player fade if stayout flag is enabled.

mp/src/game/server/EnvFade.cpp and sp/src/game/server/EnvFade.cpp have the same bug.

// Current Code
void CEnvFade::InputFade( inputdata_t &inputdata )
{
    int fadeFlags = 0;

    if ( m_spawnflags & SF_FADE_IN )
    {
        fadeFlags |= FFADE_IN;
    }
    else
    {
        fadeFlags |= FFADE_OUT;
    }

    if ( m_spawnflags & SF_FADE_MODULATE )
    {
        fadeFlags |= FFADE_MODULATE;
    }

    if ( m_spawnflags & SF_FADE_STAYOUT )
    {
        fadeFlags |= FFADE_STAYOUT;
    }

    if ( m_spawnflags & SF_FADE_ONLYONE )
    {
        if ( inputdata.pActivator && inputdata.pActivator->IsNetClient() )
        {
            // Line below is missing important flag, FFADE_PURGE.
            UTIL_ScreenFade( inputdata.pActivator, m_clrRender, Duration(), HoldTime(), fadeFlags );
        }
    }
    else
    {
        UTIL_ScreenFadeAll( m_clrRender, Duration(), HoldTime(), fadeFlags|FFADE_PURGE );
    }

    m_OnBeginFade.FireOutput( inputdata.pActivator, this );
}

// Working Code
void CEnvFade::InputFade( inputdata_t &inputdata )
{
    int fadeFlags = 0;

    if ( m_spawnflags & SF_FADE_IN )
    {
        fadeFlags |= FFADE_IN;
    }
    else
    {
        fadeFlags |= FFADE_OUT;
    }

    if ( m_spawnflags & SF_FADE_MODULATE )
    {
        fadeFlags |= FFADE_MODULATE;
    }

    if ( m_spawnflags & SF_FADE_STAYOUT )
    {
        fadeFlags |= FFADE_STAYOUT;
    }

    if ( m_spawnflags & SF_FADE_ONLYONE )
    {
        if ( inputdata.pActivator && inputdata.pActivator->IsNetClient() )
        {
            // Contains FFADE_PURGE which allows you to do fade in if you've done fade out with stayout flag enabled.
            UTIL_ScreenFade( inputdata.pActivator, m_clrRender, Duration(), HoldTime(), fadeFlags | FFADE_PURGE );
        }
    }
    else
    {
        UTIL_ScreenFadeAll( m_clrRender, Duration(), HoldTime(), fadeFlags | FFADE_PURGE);
    }

    m_OnBeginFade.FireOutput( inputdata.pActivator, this );
}

// Reference from fadein and fadeout command functions
// Fade Out
UTIL_ScreenFade( pPlayer, clrFade, flTime, 0, FFADE_OUT | FFADE_PURGE | FFADE_STAYOUT );
// Fade In
UTIL_ScreenFade( pPlayer, clrFade, flTime, 0, FFADE_IN | FFADE_PURGE );