@@ -685,27 +685,29 @@ protected override void UpdateTractiveForce(float elapsedClockSeconds, float t,
685685
686686 if ( TractiveForceCurves == null )
687687 {
688- // This sets the maximum force of the locomotive, it will be adjusted down if it exceeds the max power of the locomotive.
689- float maxForceN = Math . Min ( t * MaxForceN * ( 1 - PowerReduction ) , AbsTractionSpeedMpS == 0.0f ? ( t * MaxForceN * ( 1 - PowerReduction ) ) : ( t * LocomotiveMaxRailOutputPowerW / AbsTractionSpeedMpS ) ) ;
690-
691- // Maximum rail power is reduced by apparent throttle factor and the number of engines running (power ratio)
692- float maxPowerW = LocomotiveMaxRailOutputPowerW * DieselEngineFractionPower * LocomotiveApparentThrottleSetting ;
693-
694- // If unloading speed is in ENG file, and locomotive speed is greater then unloading speed, and less then max speed, then apply a decay factor to the power/force
695- if ( UnloadingSpeedMpS != 0 && AbsTractionSpeedMpS > UnloadingSpeedMpS && AbsTractionSpeedMpS < MaxSpeedMpS && ! WheelSlip )
696- {
697- // use straight line curve to decay power to zero by 2 x unloading speed
698- float unloadingspeeddecay = 1.0f - ( 1.0f / UnloadingSpeedMpS ) * ( AbsTractionSpeedMpS - UnloadingSpeedMpS ) ;
699- unloadingspeeddecay = MathHelper . Clamp ( unloadingspeeddecay , 0.0f , 1.0f ) ; // Clamp decay within bounds
700- maxPowerW *= unloadingspeeddecay ;
701- }
702-
703688 if ( DieselEngines . HasGearBox )
704689 {
705690 TractiveForceN = DieselEngines . TractiveForceN ;
706691 }
707692 else
708693 {
694+ // This sets the maximum force of the locomotive, it will be adjusted down if it exceeds the max power of the locomotive.
695+ float maxForceN = Math . Min ( t * MaxForceN * ( 1 - PowerReduction ) , AbsTractionSpeedMpS == 0.0f ? ( t * MaxForceN * ( 1 - PowerReduction ) ) : ( t * LocomotiveMaxRailOutputPowerW / AbsTractionSpeedMpS ) ) ;
696+
697+ // Maximum rail power is reduced by apparent throttle factor and the number of engines running (power ratio)
698+ float maxPowerW = LocomotiveMaxRailOutputPowerW * DieselEngineFractionPower * LocomotiveApparentThrottleSetting ;
699+
700+ if ( DieselPowerSupply . MaximumPowerW > 0 )
701+ maxPowerW = Math . Min ( maxPowerW , DieselPowerSupply . MaximumPowerW * LocomotiveApparentThrottleSetting ) ;
702+
703+ // If unloading speed is in ENG file, and locomotive speed is greater then unloading speed, and less then max speed, then apply a decay factor to the power/force
704+ if ( UnloadingSpeedMpS != 0 && AbsTractionSpeedMpS > UnloadingSpeedMpS && AbsTractionSpeedMpS < MaxSpeedMpS && ! WheelSlip )
705+ {
706+ // use straight line curve to decay power to zero by 2 x unloading speed
707+ float unloadingspeeddecay = 1.0f - ( 1.0f / UnloadingSpeedMpS ) * ( AbsTractionSpeedMpS - UnloadingSpeedMpS ) ;
708+ unloadingspeeddecay = MathHelper . Clamp ( unloadingspeeddecay , 0.0f , 1.0f ) ; // Clamp decay within bounds
709+ maxPowerW *= unloadingspeeddecay ;
710+ }
709711 if ( maxForceN * AbsSpeedMpS > maxPowerW )
710712 maxForceN = maxPowerW / AbsTractionSpeedMpS ;
711713
@@ -725,6 +727,12 @@ protected override void UpdateTractiveForce(float elapsedClockSeconds, float t,
725727 {
726728 // Tractive force is read from Table using the apparent throttle setting, and then reduced by the number of engines running (power ratio)
727729 TractiveForceN = TractiveForceCurves . Get ( LocomotiveApparentThrottleSetting , AbsTractionSpeedMpS ) * DieselEngineFractionPower * ( 1 - PowerReduction ) ;
730+ if ( DieselPowerSupply . MaximumPowerW > 0 )
731+ {
732+ float maxPowerW = DieselPowerSupply . MaximumPowerW * t ;
733+ if ( TractiveForceN * AbsTractionSpeedMpS > maxPowerW )
734+ TractiveForceN = maxPowerW / AbsTractionSpeedMpS ;
735+ }
728736 }
729737
730738 if ( TractiveForceN < 0 && ! TractiveForceCurves . AcceptsNegativeValues ( ) )
0 commit comments