@@ -4784,6 +4784,9 @@ void TintEnvelope::setDecayFrames( UnsignedInt frames )
47844784// -------------------------------------------------------------------------------------------------
47854785void TintEnvelope::update (void )
47864786{
4787+ // TheSuperHackers @tweak The tint time step is now decoupled from the render update.
4788+ const Real timeScale = TheGameEngine->getActualLogicTimeScaleOverFpsRatio ();
4789+
47874790 switch ( m_envState )
47884791 {
47894792 case ( ENVELOPE_STATE_REST ) : // most likely case
@@ -4794,25 +4797,31 @@ void TintEnvelope::update(void)
47944797 }
47954798 case ( ENVELOPE_STATE_DECAY ) : // much more likely than attack
47964799 {
4797- if (m_decayRate.Length () > m_currentColor.Length () || m_currentColor.Length () <= FADE_RATE_EPSILON) // we are at rest
4800+ const Vector3 decayRate = m_decayRate * timeScale;
4801+
4802+ if (decayRate.Length () > m_currentColor.Length () || m_currentColor.Length () <= FADE_RATE_EPSILON)
47984803 {
4804+ // We are at rest
47994805 m_envState = ENVELOPE_STATE_REST;
48004806 m_affect = FALSE ;
48014807 }
48024808 else
48034809 {
4804- Vector3::Add ( m_decayRate, m_currentColor, &m_currentColor );// Add the decayRate to the current color;
4810+ // Add the decayRate to the current color
4811+ Vector3::Add ( decayRate, m_currentColor, &m_currentColor );
48054812 m_affect = TRUE ;
48064813 }
48074814 break ;
48084815 }
48094816 case ( ENVELOPE_STATE_ATTACK ) :
48104817 {
4818+ const Vector3 attackRate = m_attackRate * timeScale;
48114819 Vector3 delta;
48124820 Vector3::Subtract (m_currentColor, m_peakColor, &delta);
48134821
4814- if (m_attackRate .Length () > delta.Length () || delta.Length () <= FADE_RATE_EPSILON) // we are at the peak
4822+ if (attackRate .Length () > delta.Length () || delta.Length () <= FADE_RATE_EPSILON)
48154823 {
4824+ // We are at the peak
48164825 if ( m_sustainCounter )
48174826 {
48184827 m_envState = ENVELOPE_STATE_SUSTAIN;
@@ -4821,20 +4830,20 @@ void TintEnvelope::update(void)
48214830 {
48224831 m_envState = ENVELOPE_STATE_DECAY;
48234832 }
4824-
48254833 }
48264834 else
48274835 {
4828- Vector3::Add ( m_attackRate, m_currentColor, &m_currentColor );// Add the attackRate to the current color;
4836+ // Add the attackRate to the current color
4837+ Vector3::Add ( attackRate, m_currentColor, &m_currentColor );
48294838 m_affect = TRUE ;
48304839 }
48314840
48324841 break ;
48334842 }
48344843 case ( ENVELOPE_STATE_SUSTAIN ) :
48354844 {
4836- if ( m_sustainCounter > 0 )
4837- -- m_sustainCounter;
4845+ if ( m_sustainCounter > 0 . 0f )
4846+ m_sustainCounter -= timeScale ;
48384847 else
48394848 release ();
48404849
@@ -4867,7 +4876,11 @@ void TintEnvelope::xfer( Xfer *xfer )
48674876{
48684877
48694878 // version
4879+ #if RETAIL_COMPATIBLE_XFER_SAVE
48704880 XferVersion currentVersion = 1 ;
4881+ #else
4882+ XferVersion currentVersion = 2 ;
4883+ #endif
48714884 XferVersion version = currentVersion;
48724885 xfer->xferVersion ( &version, currentVersion );
48734886
@@ -4884,7 +4897,16 @@ void TintEnvelope::xfer( Xfer *xfer )
48844897 xfer->xferUser ( &m_currentColor, sizeof ( Vector3 ) );
48854898
48864899 // sustain counter
4887- xfer->xferUnsignedInt ( &m_sustainCounter );
4900+ if (version <= 1 )
4901+ {
4902+ UnsignedInt sustainCounter = (UnsignedInt)m_sustainCounter;
4903+ xfer->xferUnsignedInt ( &sustainCounter );
4904+ m_sustainCounter = (Real)sustainCounter;
4905+ }
4906+ else
4907+ {
4908+ xfer->xferReal ( &m_sustainCounter );
4909+ }
48884910
48894911 // affect
48904912 xfer->xferBool ( &m_affect );
0 commit comments