@@ -2526,6 +2526,7 @@ public void UpdateForceWithRamp(ref float forceN, float elapsedClockSeconds, flo
25262526 {
25272527 if ( targetForceN > maxForceN ) targetForceN = maxForceN ;
25282528 if ( forceN > maxForceN ) forceN = maxForceN ;
2529+ bool toZero = targetForceN == 0 ;
25292530 if ( AbsTractionSpeedMpS > 0 )
25302531 {
25312532 float powerW = forceN * PrevAbsTractionSpeedMpS ;
@@ -2539,23 +2540,25 @@ public void UpdateForceWithRamp(ref float forceN, float elapsedClockSeconds, flo
25392540 targetForceN = Math . Min ( targetForceN , targetPowerW / AbsTractionSpeedMpS ) ;
25402541 }
25412542 }
2542- if ( targetPowerW < powerW && ( targetPowerW == 0 ? rampZeroWpS : rampDownWpS ) > 0 )
2543+ if ( targetPowerW < powerW && ( toZero ? rampZeroWpS : rampDownWpS ) > 0 )
25432544 {
2544- float maxChangeW = ( targetPowerW == 0 ? rampZeroWpS : rampDownWpS ) * elapsedClockSeconds ;
2545+ float maxChangeW = ( toZero ? rampZeroWpS : rampDownWpS ) * elapsedClockSeconds ;
25452546 if ( powerW - maxChangeW > targetPowerW )
25462547 {
25472548 targetPowerW = powerW - maxChangeW ;
25482549 targetForceN = Math . Max ( targetForceN , Math . Min ( forceN , targetPowerW / AbsTractionSpeedMpS ) ) ;
25492550 }
25502551 }
25512552 }
2552- if ( targetForceN > forceN && rampUpNpS > 0 )
2553+ if ( targetForceN > forceN )
25532554 {
2554- forceN = Math . Min ( targetForceN , forceN + rampUpNpS * elapsedClockSeconds ) ;
2555+ if ( rampUpNpS > 0 ) forceN = Math . Min ( forceN + rampUpNpS * elapsedClockSeconds , targetForceN ) ;
2556+ else forceN = targetForceN ;
25552557 }
2556- else if ( targetForceN < forceN && ( targetForceN == 0 ? rampZeroNpS : rampDownNpS ) > 0 )
2558+ else if ( targetForceN < forceN )
25572559 {
2558- forceN = Math . Max ( targetForceN , forceN - ( targetForceN == 0 ? rampZeroNpS : rampDownNpS ) * elapsedClockSeconds ) ;
2560+ if ( ( toZero ? rampZeroNpS : rampDownNpS ) > 0 ) forceN = Math . Max ( forceN - ( toZero ? rampZeroNpS : rampDownNpS ) * elapsedClockSeconds , targetForceN ) ;
2561+ else forceN = targetForceN ;
25592562 }
25602563 }
25612564 /// <summary>
@@ -2611,7 +2614,7 @@ protected virtual void UpdateTractionForce(float elapsedClockSeconds)
26112614 // Ensure that throttle never exceeds the limits imposed by other subsystems
26122615 float maxthrottle = MaxThrottlePercent / 100 ;
26132616 // For diesel locomotives, also take into account the throttle setting associated to the current engine RPM
2614- if ( IsPlayerTrain && this is MSTSDieselLocomotive diesel ) maxthrottle = Math . Min ( maxthrottle , diesel . DieselEngines . ApparentThrottleSetting / 100.0f ) ;
2617+ if ( IsPlayerTrain && this is MSTSDieselLocomotive diesel && ! diesel . TractiveForcePowerLimited ) maxthrottle = Math . Min ( maxthrottle , diesel . DieselEngines . ApparentThrottleSetting / 100.0f ) ;
26152618 if ( t > maxthrottle ) t = maxthrottle ;
26162619 t = MathHelper . Clamp ( t , 0 , 1 ) ;
26172620
0 commit comments