upload "kind" alien swarm

This commit is contained in:
nillerusr
2023-10-03 17:23:56 +03:00
parent b7bd94c52e
commit 7d3c0d8b5a
4229 changed files with 462903 additions and 495158 deletions

View File

@@ -1,4 +1,4 @@
//========= Copyright Valve Corporation, All rights reserved. ============//
//========= Copyright 1996-2005, Valve Corporation, All rights reserved. ============//
//
// Purpose:
//
@@ -15,8 +15,7 @@
#include "con_nprint.h"
#include "saverestoretypes.h"
#include "c_rumble.h"
// NVNT haptics interface system
#include "haptics/ihaptics.h"
#include "prediction.h"
// memdbgon must be the last include file in a .cpp file!!!
#include "tier0/memdbgon.h"
@@ -67,6 +66,21 @@ struct screenshake_t
Vector offset;
float angle;
int command;
Vector direction; // used only by kSHAKE_DIRECTIONAL
// there are different types of screenshake --
// eventually these different types could become
// proper classes, but given the existing infrastructure
// for transmitting screenshakes, right now it's just
// easier to use an enum and switch.
enum ShakeType_t
{
kSHAKE_BASIC, ///< the original screenshake mechanism, a random offset selected every few frames.
kSHAKE_DIRECTIONAL, ///< a pseudo-damped-spring-ish punch to a specific screen space direction.
};
uint8 nShakeType; // actually a ShakeType_t, packed into eight bits (the datadesc system doesn't like bitfields)
screenshake_t() : nShakeType(kSHAKE_BASIC) {}; // nothing else is explicitly initialized
DECLARE_SIMPLE_DATADESC();
};
@@ -79,10 +93,39 @@ BEGIN_SIMPLE_DATADESC( screenshake_t )
DEFINE_FIELD( nextShake, FIELD_TIME ),
DEFINE_FIELD( offset, FIELD_VECTOR ),
DEFINE_FIELD( angle, FIELD_FLOAT ),
DEFINE_FIELD( nShakeType, FIELD_CHARACTER ),
DEFINE_FIELD( direction, FIELD_VECTOR ),
END_DATADESC()
void CC_Shake_Stop();
//-----------------------------------------------------------------------------
// Purpose: Screen tilt variables
//-----------------------------------------------------------------------------
struct screentilt_t
{
bool easeInOut;
QAngle angle;
float starttime;
float endtime;
float duration;
float tiltTime;
Vector offset;
int command;
DECLARE_SIMPLE_DATADESC();
};
BEGIN_SIMPLE_DATADESC( screentilt_t )
DEFINE_FIELD( angle, FIELD_VECTOR ),
DEFINE_FIELD( starttime, FIELD_TIME ),
DEFINE_FIELD( endtime, FIELD_TIME ),
DEFINE_FIELD( duration, FIELD_FLOAT ),
DEFINE_FIELD( tiltTime, FIELD_TIME ),
DEFINE_FIELD( offset, FIELD_VECTOR ),
END_DATADESC()
//-----------------------------------------------------------------------------
// Purpose: Implements the view effects interface for the client .dll
//-----------------------------------------------------------------------------
@@ -100,8 +143,11 @@ public:
virtual void GetFadeParams( byte *r, byte *g, byte *b, byte *a, bool *blend );
virtual void CalcShake( void );
virtual void ApplyShake( Vector& origin, QAngle& angles, float factor );
virtual void CalcTilt( void );
virtual void ApplyTilt( QAngle& angles, float factor );
virtual void Shake( ScreenShake_t &data );
virtual void Shake( const ScreenShake_t &data );
virtual void Tilt( ScreenTilt_t &data );
virtual void Fade( ScreenFade_t &data );
virtual void ClearPermanentFades( void );
virtual void FadeCalculate( void );
@@ -116,20 +162,41 @@ private:
void ClearAllShakes();
screenshake_t *FindLongestShake();
void ClearAllTilts();
screentilt_t *FindLongestTilt();
// helper subfunctions used inside CalcShake
void CalcShake_Basic( screenshake_t * pShake, float * RESTRICT pflRumbleAngle );
void CalcShake_Directional( screenshake_t * pShake, float * RESTRICT pflRumbleAngle );
CUtlVector<screenfade_t *> m_FadeList;
CUtlVector<screenshake_t *> m_ShakeList;
Vector m_vecShakeAppliedOffset;
float m_flShakeAppliedAngle;
CUtlVector<screentilt_t *> m_TiltList;
QAngle m_vecTiltAppliedAngle;
int m_FadeColorRGBA[4];
bool m_bModulate;
friend void CC_Shake_Stop();
};
static CViewEffects g_ViewEffects;
IViewEffects *vieweffects = ( IViewEffects * )&g_ViewEffects;
static CViewEffects g_ViewEffects[ MAX_SPLITSCREEN_PLAYERS ];
IViewEffects *GetViewEffects()
{
ASSERT_LOCAL_PLAYER_RESOLVABLE();
return &g_ViewEffects[ GET_ACTIVE_SPLITSCREEN_SLOT() ];
}
static CViewEffects &GetCViewEffects()
{
ASSERT_LOCAL_PLAYER_RESOLVABLE();
return g_ViewEffects[ GET_ACTIVE_SPLITSCREEN_SLOT() ];
}
// Callback function to call at end of screen m_Fade.
static int s_nCallbackParameter;
@@ -147,12 +214,61 @@ void __MsgFunc_Shake( bf_read &msg )
{
ScreenShake_t shake;
shake.command = msg.ReadByte();
shake.command = (ShakeCommand_t)(msg.ReadByte());
shake.amplitude = msg.ReadFloat();
shake.frequency = msg.ReadFloat();
shake.duration = msg.ReadFloat();
g_ViewEffects.Shake( shake );
GetCViewEffects().Shake( shake );
}
//-----------------------------------------------------------------------------
// Purpose:
// Input : *pszName -
// iSize -
// *pbuf -
// Output : static int
//-----------------------------------------------------------------------------
void __MsgFunc_ShakeDir( bf_read &msg )
{
if ( prediction && prediction->InPrediction() && !prediction->IsFirstTimePredicted() )
return;
ScreenShake_t shake;
shake.command = (ShakeCommand_t)msg.ReadByte();
shake.amplitude = msg.ReadFloat();
shake.frequency = msg.ReadFloat();
shake.duration = msg.ReadFloat();
msg.ReadBitVec3Normal( shake.direction );
GetCViewEffects().Shake( shake );
}
//-----------------------------------------------------------------------------
// Purpose:
// Input : *pszName -
// iSize -
// *pbuf -
// Output : static int
//-----------------------------------------------------------------------------
void __MsgFunc_Tilt( bf_read &msg )
{
ScreenTilt_t tilt;
Vector vecAngle;
tilt.command = msg.ReadByte();
tilt.easeInOut = msg.ReadByte() ? true : false;
tilt.angle.x = msg.ReadFloat();
tilt.angle.y = msg.ReadFloat();
tilt.angle.z = msg.ReadFloat();
tilt.duration = msg.ReadFloat();
tilt.time = msg.ReadFloat();
GetCViewEffects().Tilt( tilt );
}
//-----------------------------------------------------------------------------
@@ -174,7 +290,7 @@ void __MsgFunc_Fade( bf_read &msg )
fade.b = msg.ReadByte(); // fade blue
fade.a = msg.ReadByte(); // fade blue
g_ViewEffects.Fade( fade );
GetCViewEffects().Fade( fade );
}
//-----------------------------------------------------------------------------
@@ -183,6 +299,13 @@ void __MsgFunc_Fade( bf_read &msg )
void CViewEffects::Init( void )
{
HOOK_MESSAGE( Shake );
#ifdef INFESTED_DLL // the user message ShakeDir isn't registered for other games, but if you add it to your RegisterUserMessages, then you can un-#ifdef this
HOOK_MESSAGE( ShakeDir ); // directional screen shake
#endif
#ifdef HL2_CLIENT
// @TODO: Jeep, this causes assert in other games w/o this guard ifdef [6/3/2008 tom]
HOOK_MESSAGE( Tilt );
#endif
HOOK_MESSAGE( Fade );
}
@@ -192,6 +315,7 @@ void CViewEffects::Init( void )
void CViewEffects::LevelInit( void )
{
ClearAllShakes();
ClearAllTilts();
ClearAllFades();
}
@@ -204,38 +328,70 @@ static ConCommand shake_stop("shake_stop", CC_Shake_Stop, "Stops all active scre
//-----------------------------------------------------------------------------
void CC_Shake_Stop()
{
g_ViewEffects.ClearAllShakes();
GetCViewEffects().ClearAllShakes();
}
//-----------------------------------------------------------------------------
// Purpose: Test a punch-type screen shake
//-----------------------------------------------------------------------------
void CC_Shake_TestPunch( const CCommand &args )
{
if ( args.ArgC() < 7 )
{
Msg("Usage: %s x y z f a d\n"
"where x,y,z are direction of screen punch\n"
" f is frequency (1 means three bounces before settling)\n"
" a is amplitude\n"
" d is duration\n",
args[0] );
}
const float x = atof( args[1] );
const float y = atof( args[2] );
const float z = atof( args[3] );
const float f = atof( args[4] );
const float a = atof( args[5] );
const float d = atof( args[6] );
ScreenShake_t shake;
shake.command = SHAKE_START;
shake.amplitude = a;
shake.frequency = f;
shake.duration = d;
shake.direction = Vector(x,y,z);
GetCViewEffects().Shake(shake);
}
static ConCommand shake_testpunch("shake_testpunch", CC_Shake_TestPunch, "Test a punch-style screen shake.\n", FCVAR_CHEAT );
//-----------------------------------------------------------------------------
// Purpose: Apply noise to the eye position.
// UNDONE: Feedback a bit of this into the view model position. It shakes too much
//-----------------------------------------------------------------------------
void CViewEffects::CalcShake( void )
{
float fraction, freq;
// We'll accumulate the aggregate shake for this frame into these data members.
m_vecShakeAppliedOffset.Init(0, 0, 0);
m_flShakeAppliedAngle = 0;
float flRumbleAngle = 0;
// NVNT - haptic shake effect amplitude
float hapticShakeAmp = 0;
bool bShow = shake_show.GetBool();
int nShakeCount = m_ShakeList.Count();
for ( int nShake = nShakeCount - 1; nShake >= 0; nShake-- )
{
screenshake_t *pShake = m_ShakeList.Element( nShake );
screenshake_t * RESTRICT pShake = m_ShakeList.Element( nShake );
if ( pShake->endtime == 0 )
{
// Shouldn't be any such shakes in the list.
Assert( false );
AssertMsg( false, "A screenshake has null endtime in CViewEffects::CalcShake\n" );
continue;
}
@@ -263,72 +419,130 @@ void CViewEffects::CalcShake( void )
engine->Con_NXPrintf( &np, "%02d: dur(%8.2f) amp(%8.2f) freq(%8.2f)", nShake + 1, (double)pShake->duration, (double)pShake->amplitude, (double)pShake->frequency );
}
if ( gpGlobals->curtime > pShake->nextShake )
// select the appropriate behavior based on screenshake type
switch ( pShake->nShakeType )
{
// Higher frequency means we recalc the extents more often and perturb the display again
pShake->nextShake = gpGlobals->curtime + (1.0f / pShake->frequency);
// Compute random shake extents (the shake will settle down from this)
for (int i = 0; i < 3; i++ )
{
pShake->offset[i] = random->RandomFloat( -pShake->amplitude, pShake->amplitude );
}
pShake->angle = random->RandomFloat( -pShake->amplitude*0.25, pShake->amplitude*0.25 );
case screenshake_t::kSHAKE_BASIC:
CalcShake_Basic( pShake, &flRumbleAngle );
break;
case screenshake_t::kSHAKE_DIRECTIONAL:
CalcShake_Directional( pShake, &flRumbleAngle );
break;
default:
AssertMsg1( false, "Unknown shake type %d\n", pShake->nShakeType );
}
// Ramp down amplitude over duration (fraction goes from 1 to 0 linearly with slope 1/duration)
fraction = ( pShake->endtime - gpGlobals->curtime ) / pShake->duration;
// Ramp up frequency over duration
if ( fraction )
{
freq = (pShake->frequency / fraction);
}
else
{
freq = 0;
}
// square fraction to approach zero more quickly
fraction *= fraction;
// Sine wave that slowly settles to zero
float angle = gpGlobals->curtime * freq;
if ( angle > 1e8 )
{
angle = 1e8;
}
fraction = fraction * sin( angle );
if( pShake->command != SHAKE_START_NORUMBLE )
{
// As long as this isn't a NO RUMBLE effect, then accumulate rumble
flRumbleAngle += pShake->angle * fraction;
}
if( pShake->command != SHAKE_START_RUMBLEONLY )
{
// As long as this isn't a RUMBLE ONLY effect, then accumulate screen shake
// Add to view origin
m_vecShakeAppliedOffset += pShake->offset * fraction;
// Add to roll
m_flShakeAppliedAngle += pShake->angle * fraction;
}
// Drop amplitude a bit, less for higher frequency shakes
pShake->amplitude -= pShake->amplitude * ( gpGlobals->frametime / (pShake->duration * pShake->frequency) );
// NVNT - update our amplitude.
hapticShakeAmp += pShake->amplitude*fraction;
}
// NVNT - apply our screen shake update
if ( haptics )
haptics->SetShake(hapticShakeAmp,1);
// Feed this to the rumble system!
UpdateScreenShakeRumble( flRumbleAngle );
UpdateScreenShakeRumble( XBX_GetActiveUserId(), flRumbleAngle );
}
void CViewEffects::CalcShake_Basic( screenshake_t * RESTRICT pShake, float * RESTRICT pflRumbleAngle )
{
float fraction, freq;
if ( gpGlobals->curtime > pShake->nextShake )
{
// Higher frequency means we recalc the extents more often and perturb the display again
pShake->nextShake = gpGlobals->curtime + (1.0f / pShake->frequency);
// Compute random shake extents (the shake will settle down from this)
for (int i = 0; i < 3; i++ )
{
pShake->offset[i] = random->RandomFloat( -pShake->amplitude, pShake->amplitude );
}
pShake->angle = random->RandomFloat( -pShake->amplitude*0.25, pShake->amplitude*0.25 );
}
// Ramp down amplitude over duration (fraction goes from 1 to 0 linearly with slope 1/duration)
fraction = ( pShake->endtime - gpGlobals->curtime ) / pShake->duration;
// Ramp up frequency over duration
if ( fraction )
{
freq = (pShake->frequency / fraction);
}
else
{
freq = 0;
}
// square fraction to approach zero more quickly
fraction *= fraction;
// Sine wave that slowly settles to zero
float angle = gpGlobals->curtime * freq;
if ( angle > 1e8 )
{
angle = 1e8;
}
fraction = fraction * sin( angle );
if( pShake->command != SHAKE_START_NORUMBLE )
{
// As long as this isn't a NO RUMBLE effect, then accumulate rumble
*pflRumbleAngle += pShake->angle * fraction;
}
if( pShake->command != SHAKE_START_RUMBLEONLY )
{
// As long as this isn't a RUMBLE ONLY effect, then accumulate screen shake
// Add to view origin
m_vecShakeAppliedOffset += pShake->offset * fraction;
// Add to roll
m_flShakeAppliedAngle += pShake->angle * fraction;
}
// Drop amplitude a bit, less for higher frequency shakes
pShake->amplitude -= pShake->amplitude * ( gpGlobals->frametime / (pShake->duration * pShake->frequency) );
}
void CViewEffects::CalcShake_Directional( screenshake_t * RESTRICT pShake, float * RESTRICT pflRumbleAngle )
{
// a screen punch follows an equation of the form
// y = sin(fx) * ( 1 - x / (3pi) ) for x=0..3pi
// where the duration is transformed to occupy
// the region 0..3pi
// and the frequency can be any number (which controls the number of oscillations
// before lapsing out)
// because of the resolution of this shake, it is performed every frame
// (ignores nextShake)
pShake->nextShake = gpGlobals->curtime + 0.001;
float t = 1 - ( pShake->endtime - gpGlobals->curtime ) / pShake->duration; // t varies 0 .. 1 over life of shake
float fraction = ( 1 - t ); // compiler will hopefully elide the double subtraction
// transform the duration and so that x varies 0 .. 3PI over lifespan
t *= ( 3 * M_PI ); // t varies 0 .. 3PI
const float x = t * pShake->frequency;
const float y = sin(x) * fraction;
// transform this -1..1 sinusoid by amplitude and direction
pShake->offset = pShake->direction * ( pShake->amplitude * y );
if( pShake->command != SHAKE_START_NORUMBLE )
{
// As long as this isn't a NO RUMBLE effect, then accumulate rumble
*pflRumbleAngle += y;
}
if( pShake->command != SHAKE_START_RUMBLEONLY )
{
// As long as this isn't a RUMBLE ONLY effect, then accumulate screen shake
// Add to view origin
m_vecShakeAppliedOffset += pShake->offset ;
}
}
@@ -345,6 +559,92 @@ void CViewEffects::ApplyShake( Vector& origin, QAngle& angles, float factor )
angles.z += m_flShakeAppliedAngle * factor;
}
//-----------------------------------------------------------------------------
// Purpose: Apply noise to the eye position.
// UNDONE: Feedback a bit of this into the view model position. It shakes too much
//-----------------------------------------------------------------------------
void CViewEffects::CalcTilt( void )
{
m_vecTiltAppliedAngle.Init();
int nTiltCount = m_TiltList.Count();
for ( int nTilt = nTiltCount - 1; nTilt >= 0; nTilt-- )
{
screentilt_t *pTilt = m_TiltList.Element( nTilt );
if ( pTilt->endtime == 0 )
{
// Shouldn't be any such tilts in the list.
Assert( false );
continue;
}
if ( ( gpGlobals->curtime > pTilt->endtime ) ||
pTilt->duration <= 0 || pTilt->angle == QAngle( 0.0f, 0.0f, 0.0f ) )
{
// Retire this tilt.
delete m_TiltList.Element( nTilt );
m_TiltList.FastRemove( nTilt );
continue;
}
float flInterp = ( gpGlobals->curtime - pTilt->starttime ) / pTilt->tiltTime;
float flReturnInterp = ( pTilt->endtime - gpGlobals->curtime ) / pTilt->tiltTime;
if ( flReturnInterp < flInterp )
{
flInterp = flReturnInterp;
}
float flSmoothInterp = clamp( flInterp, 0.0f, 1.0f );
if ( pTilt->easeInOut )
{
// Do a smooth ease in and out
flSmoothInterp = 1.0f - 0.5f * ( cosf( flSmoothInterp * M_PI ) + 1.0f );
}
// Accumulate world tilt
m_vecTiltAppliedAngle += pTilt->angle * flSmoothInterp;
}
}
//-----------------------------------------------------------------------------
// Purpose: Apply the current screen shake to this origin/angles. Factor is the amount to apply
// This is so you can blend in part of the shake
// Input : origin -
// angles -
// factor -
//-----------------------------------------------------------------------------
void CViewEffects::ApplyTilt( QAngle& angles, float factor )
{
if ( m_vecTiltAppliedAngle == QAngle( 0.0f, 0.0f, 0.0f ) )
{
// Fast out, no tilt to apply
return;
}
matrix3x4_t matTilt;
AngleIMatrix( m_vecTiltAppliedAngle, matTilt );
matrix3x4_t matToWorld;
AngleMatrix( angles, matToWorld );
matrix3x4_t matTiltToWorld;
ConcatTransforms( matTilt, matToWorld, matTiltToWorld);
Vector vecForwardTilted, vecUpTilted;
VectorTransform( Vector( 1.0f, 0.0, 0.0f ), matTiltToWorld, vecForwardTilted );
VectorTransform( Vector( 0.0f, 0.0, 1.0f ), matTiltToWorld, vecUpTilted );
QAngle anglesTilted;
VectorAngles( vecForwardTilted, vecUpTilted, anglesTilted );
angles = anglesTilted;
}
//-----------------------------------------------------------------------------
// Purpose: Zeros out all active screen shakes.
@@ -392,18 +692,29 @@ screenshake_t *CViewEffects::FindLongestShake()
// pbuf -
// Output :
//-----------------------------------------------------------------------------
void CViewEffects::Shake( ScreenShake_t &data )
void CViewEffects::Shake( const ScreenShake_t &data )
{
if ( prediction && prediction->InPrediction() && !prediction->IsFirstTimePredicted() )
return;
if ( ( data.command == SHAKE_START || data.command == SHAKE_START_RUMBLEONLY ) && ( m_ShakeList.Count() < MAX_SHAKES ) )
{
screenshake_t *pNewShake = new screenshake_t;
screenshake_t * RESTRICT pNewShake = new screenshake_t; // ugh, should just make these a static array
pNewShake->amplitude = data.amplitude;
pNewShake->frequency = data.frequency;
pNewShake->duration = data.duration;
pNewShake->nextShake = 0;
pNewShake->endtime = gpGlobals->curtime + data.duration;
if ( prediction && prediction->InPrediction() )
{
pNewShake->endtime = prediction->GetSavedTime() + data.duration;
}
pNewShake->command = data.command;
pNewShake->direction = data.direction;
pNewShake->nShakeType = data.direction.IsZeroFast() ? screenshake_t::kSHAKE_BASIC : screenshake_t::kSHAKE_DIRECTIONAL;
m_ShakeList.AddToTail( pNewShake );
}
@@ -414,7 +725,7 @@ void CViewEffects::Shake( ScreenShake_t &data )
else if ( data.command == SHAKE_AMPLITUDE )
{
// Look for the most likely shake to modify.
screenshake_t *pShake = FindLongestShake();
screenshake_t * RESTRICT pShake = FindLongestShake();
if ( pShake )
{
pShake->amplitude = data.amplitude;
@@ -423,7 +734,7 @@ void CViewEffects::Shake( ScreenShake_t &data )
else if ( data.command == SHAKE_FREQUENCY )
{
// Look for the most likely shake to modify.
screenshake_t *pShake = FindLongestShake();
screenshake_t * RESTRICT pShake = FindLongestShake();
if ( pShake )
{
pShake->frequency = data.frequency;
@@ -431,6 +742,74 @@ void CViewEffects::Shake( ScreenShake_t &data )
}
}
//-----------------------------------------------------------------------------
// Purpose: Zeros out all active screen tilts.
//-----------------------------------------------------------------------------
void CViewEffects::ClearAllTilts()
{
int nTiltCount = m_TiltList.Count();
for ( int i = 0; i < nTiltCount; i++ )
{
delete m_TiltList.Element( i );
}
m_TiltList.Purge();
}
//-----------------------------------------------------------------------------
// Purpose: Returns the shake with the longest duration. This is the shake we
// use anytime we get an amplitude or frequency command, because the
// most likely case is that we're modifying a shake with a long
// duration rather than a brief shake caused by an explosion, etc.
//-----------------------------------------------------------------------------
screentilt_t *CViewEffects::FindLongestTilt()
{
screentilt_t *pLongestTilt = NULL;
int nTiltCount = m_TiltList.Count();
for ( int i = 0; i < nTiltCount; i++ )
{
screentilt_t *pTilt = m_TiltList.Element( i );
if ( pTilt && ( !pLongestTilt || ( pTilt->duration > pLongestTilt->duration ) ) )
{
pLongestTilt = pTilt;
}
}
return pLongestTilt;
}
//-----------------------------------------------------------------------------
// Purpose: Message hook to parse ScreenTilt messages
// Input : pszName -
// iSize -
// pbuf -
// Output :
//-----------------------------------------------------------------------------
void CViewEffects::Tilt( ScreenTilt_t &data )
{
if ( ( data.command == SHAKE_START || data.command == SHAKE_START_RUMBLEONLY ) && ( m_ShakeList.Count() < MAX_SHAKES ) )
{
screentilt_t *pNewTilt = new screentilt_t;
pNewTilt->easeInOut = data.easeInOut;
pNewTilt->angle = data.angle;
pNewTilt->duration = data.duration;
pNewTilt->tiltTime = data.time;
pNewTilt->starttime = gpGlobals->curtime;
pNewTilt->endtime = pNewTilt->starttime + data.duration;
pNewTilt->command = data.command;
m_TiltList.AddToTail( pNewTilt );
}
else if ( data.command == SHAKE_STOP)
{
ClearAllTilts();
}
}
//-----------------------------------------------------------------------------
// Purpose: Message hook to parse ScreenFade messages
@@ -492,7 +871,7 @@ void CViewEffects::FadeCalculate( void )
{
// Cycle through all fades and remove any that have finished (work backwards)
int i;
int iSize = m_FadeList.Size();
int iSize = m_FadeList.Count();
for (i = iSize-1; i >= 0; i-- )
{
screenfade_t *pFade = m_FadeList[i];
@@ -524,7 +903,7 @@ void CViewEffects::FadeCalculate( void )
m_FadeColorRGBA[0] = m_FadeColorRGBA[1] = m_FadeColorRGBA[2] = m_FadeColorRGBA[3] = 0;
// Cycle through all fades in the list and calculate the overall color/alpha
for ( i = 0; i < m_FadeList.Size(); i++ )
for ( i = 0; i < m_FadeList.Count(); i++ )
{
screenfade_t *pFade = m_FadeList[i];
@@ -564,11 +943,11 @@ void CViewEffects::FadeCalculate( void )
}
// Divide colors
if ( m_FadeList.Size() )
if ( m_FadeList.Count() )
{
m_FadeColorRGBA[0] /= m_FadeList.Size();
m_FadeColorRGBA[1] /= m_FadeList.Size();
m_FadeColorRGBA[2] /= m_FadeList.Size();
m_FadeColorRGBA[0] /= m_FadeList.Count();
m_FadeColorRGBA[1] /= m_FadeList.Count();
m_FadeColorRGBA[2] /= m_FadeList.Count();
}
}
@@ -577,7 +956,7 @@ void CViewEffects::FadeCalculate( void )
//-----------------------------------------------------------------------------
void CViewEffects::ClearPermanentFades( void )
{
int iSize = m_FadeList.Size();
int iSize = m_FadeList.Count();
for (int i = iSize-1; i >= 0; i-- )
{
screenfade_t *pFade = m_FadeList[i];
@@ -596,7 +975,7 @@ void CViewEffects::ClearPermanentFades( void )
//-----------------------------------------------------------------------------
void CViewEffects::ClearAllFades( void )
{
int iSize = m_FadeList.Size();
int iSize = m_FadeList.Count();
for (int i = iSize-1; i >= 0; i-- )
{
delete m_FadeList[i];
@@ -715,7 +1094,9 @@ class CViewEffectsSaveRestoreBlockHandler : public CDefSaveRestoreBlockHandler
{
struct QueuedItem_t;
public:
CViewEffectsSaveRestoreBlockHandler() = default;
CViewEffectsSaveRestoreBlockHandler()
{
}
const char *GetBlockName()
{
@@ -732,7 +1113,8 @@ public:
virtual void Save( ISave *pSave )
{
vieweffects->Save( pSave );
ACTIVE_SPLITSCREEN_PLAYER_GUARD( 0 );
GetViewEffects()->Save( pSave );
}
//---------------------------------
@@ -769,7 +1151,8 @@ public:
{
if ( m_bDoLoad )
{
vieweffects->Restore( pRestore, fCreatePlayers );
ACTIVE_SPLITSCREEN_PLAYER_GUARD( 0 );
GetViewEffects()->Restore( pRestore, fCreatePlayers );
}
}