Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Generals/Code/GameEngine/Include/GameClient/Drawable.h
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ class TintEnvelope : public MemoryPoolObject, public Snapshot
Vector3 m_decayRate; ///< step amount to make tint turn off slow or fast
Vector3 m_peakColor; ///< um, the peak color, what color we are headed toward during attack
Vector3 m_currentColor; ///< um, the current color, how we are colored, now
UnsignedInt m_sustainCounter;
Real m_sustainCounter;
Byte m_envState; ///< a randomly switchable SUSTAIN state, release is compliment
Bool m_affect; ///< set TRUE if this has any effect (has a non 0,0,0 color).
};
Expand Down
38 changes: 30 additions & 8 deletions Generals/Code/GameEngine/Source/GameClient/Drawable.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4784,6 +4784,9 @@ void TintEnvelope::setDecayFrames( UnsignedInt frames )
//-------------------------------------------------------------------------------------------------
void TintEnvelope::update(void)
{
// TheSuperHackers @tweak The tint time step is now decoupled from the render update.
const Real timeScale = TheGameEngine->getActualLogicTimeScaleOverFpsRatio();

switch ( m_envState )
{
case ( ENVELOPE_STATE_REST ) : //most likely case
Expand All @@ -4794,25 +4797,31 @@ void TintEnvelope::update(void)
}
case ( ENVELOPE_STATE_DECAY ) : // much more likely than attack
{
if (m_decayRate.Length() > m_currentColor.Length() || m_currentColor.Length() <= FADE_RATE_EPSILON) //we are at rest
const Vector3 decayRate = m_decayRate * timeScale;

if (decayRate.Length() > m_currentColor.Length() || m_currentColor.Length() <= FADE_RATE_EPSILON)
{
// We are at rest
m_envState = ENVELOPE_STATE_REST;
m_affect = FALSE;
}
else
{
Vector3::Add( m_decayRate, m_currentColor, &m_currentColor );//Add the decayRate to the current color;
// Add the decayRate to the current color
Vector3::Add( decayRate, m_currentColor, &m_currentColor );
m_affect = TRUE;
}
break;
}
case ( ENVELOPE_STATE_ATTACK ) :
{
const Vector3 attackRate = m_attackRate * timeScale;
Vector3 delta;
Vector3::Subtract(m_currentColor, m_peakColor, &delta);

if (m_attackRate.Length() > delta.Length() || delta.Length() <= FADE_RATE_EPSILON) //we are at the peak
if (attackRate.Length() > delta.Length() || delta.Length() <= FADE_RATE_EPSILON)
{
// We are at the peak
if ( m_sustainCounter )
{
m_envState = ENVELOPE_STATE_SUSTAIN;
Expand All @@ -4821,20 +4830,20 @@ void TintEnvelope::update(void)
{
m_envState = ENVELOPE_STATE_DECAY;
}

}
else
{
Vector3::Add( m_attackRate, m_currentColor, &m_currentColor );//Add the attackRate to the current color;
// Add the attackRate to the current color
Vector3::Add( attackRate, m_currentColor, &m_currentColor );
m_affect = TRUE;
}

break;
}
case ( ENVELOPE_STATE_SUSTAIN ) :
{
if ( m_sustainCounter > 0 )
--m_sustainCounter;
if ( m_sustainCounter > 0.0f )
m_sustainCounter -= timeScale;
else
release();

Expand Down Expand Up @@ -4867,7 +4876,11 @@ void TintEnvelope::xfer( Xfer *xfer )
{

// version
#if RETAIL_COMPATIBLE_XFER_SAVE
XferVersion currentVersion = 1;
#else
XferVersion currentVersion = 2;
#endif
XferVersion version = currentVersion;
xfer->xferVersion( &version, currentVersion );

Expand All @@ -4884,7 +4897,16 @@ void TintEnvelope::xfer( Xfer *xfer )
xfer->xferUser( &m_currentColor, sizeof( Vector3 ) );

// sustain counter
xfer->xferUnsignedInt( &m_sustainCounter );
if (version <= 1)
{
UnsignedInt sustainCounter = (UnsignedInt)m_sustainCounter;
xfer->xferUnsignedInt( &sustainCounter );
m_sustainCounter = (Real)sustainCounter;
}
else
{
xfer->xferReal( &m_sustainCounter );
}

// affect
xfer->xferBool( &m_affect );
Expand Down
2 changes: 1 addition & 1 deletion GeneralsMD/Code/GameEngine/Include/GameClient/Drawable.h
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,7 @@ class TintEnvelope : public MemoryPoolObject, public Snapshot
Vector3 m_decayRate; ///< step amount to make tint turn off slow or fast
Vector3 m_peakColor; ///< um, the peak color, what color we are headed toward during attack
Vector3 m_currentColor; ///< um, the current color, how we are colored, now
UnsignedInt m_sustainCounter;
Real m_sustainCounter;
Byte m_envState; ///< a randomly switchable SUSTAIN state, release is compliment
Bool m_affect; ///< set TRUE if this has any effect (has a non 0,0,0 color).
};
Expand Down
38 changes: 30 additions & 8 deletions GeneralsMD/Code/GameEngine/Source/GameClient/Drawable.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5541,6 +5541,9 @@ void TintEnvelope::setDecayFrames( UnsignedInt frames )
//-------------------------------------------------------------------------------------------------
void TintEnvelope::update(void)
{
// TheSuperHackers @tweak The tint time step is now decoupled from the render update.
const Real timeScale = TheGameEngine->getActualLogicTimeScaleOverFpsRatio();

switch ( m_envState )
{
case ( ENVELOPE_STATE_REST ) : //most likely case
Expand All @@ -5551,25 +5554,31 @@ void TintEnvelope::update(void)
}
case ( ENVELOPE_STATE_DECAY ) : // much more likely than attack
{
if (m_decayRate.Length() > m_currentColor.Length() || m_currentColor.Length() <= FADE_RATE_EPSILON) //we are at rest
const Vector3 decayRate = m_decayRate * timeScale;

if (decayRate.Length() > m_currentColor.Length() || m_currentColor.Length() <= FADE_RATE_EPSILON)
{
// We are at rest
m_envState = ENVELOPE_STATE_REST;
m_affect = FALSE;
}
else
{
Vector3::Add( m_decayRate, m_currentColor, &m_currentColor );//Add the decayRate to the current color;
// Add the decayRate to the current color
Vector3::Add( decayRate, m_currentColor, &m_currentColor );
m_affect = TRUE;
}
break;
}
case ( ENVELOPE_STATE_ATTACK ) :
{
const Vector3 attackRate = m_attackRate * timeScale;
Vector3 delta;
Vector3::Subtract(m_currentColor, m_peakColor, &delta);

if (m_attackRate.Length() > delta.Length() || delta.Length() <= FADE_RATE_EPSILON) //we are at the peak
if (attackRate.Length() > delta.Length() || delta.Length() <= FADE_RATE_EPSILON)
{
// We are at the peak
if ( m_sustainCounter )
{
m_envState = ENVELOPE_STATE_SUSTAIN;
Expand All @@ -5578,20 +5587,20 @@ void TintEnvelope::update(void)
{
m_envState = ENVELOPE_STATE_DECAY;
}

}
else
{
Vector3::Add( m_attackRate, m_currentColor, &m_currentColor );//Add the attackRate to the current color;
// Add the attackRate to the current color
Vector3::Add( attackRate, m_currentColor, &m_currentColor );
m_affect = TRUE;
}

break;
}
case ( ENVELOPE_STATE_SUSTAIN ) :
{
if ( m_sustainCounter > 0 )
--m_sustainCounter;
if ( m_sustainCounter > 0.0f )
m_sustainCounter -= timeScale;
else
release();

Expand Down Expand Up @@ -5624,7 +5633,11 @@ void TintEnvelope::xfer( Xfer *xfer )
{

// version
#if RETAIL_COMPATIBLE_XFER_SAVE
XferVersion currentVersion = 1;
#else
XferVersion currentVersion = 2;
#endif
XferVersion version = currentVersion;
xfer->xferVersion( &version, currentVersion );

Expand All @@ -5641,7 +5654,16 @@ void TintEnvelope::xfer( Xfer *xfer )
xfer->xferUser( &m_currentColor, sizeof( Vector3 ) );

// sustain counter
xfer->xferUnsignedInt( &m_sustainCounter );
if (version <= 1)
{
UnsignedInt sustainCounter = (UnsignedInt)m_sustainCounter;
xfer->xferUnsignedInt( &sustainCounter );
m_sustainCounter = (Real)sustainCounter;
}
else
{
xfer->xferReal( &m_sustainCounter );
}

// affect
xfer->xferBool( &m_affect );
Expand Down
Loading