@@ -408,7 +408,7 @@ public void Initialize()
408408
409409 ComputeNumberOfAxles ( ) ;
410410 if ( StartReducingSpeedDeltaDownwards == 0 ) StartReducingSpeedDeltaDownwards = StartReducingSpeedDelta ;
411- if ( StartInAutoMode ) SpeedRegMode = SpeedRegulatorMode . Auto ;
411+ if ( StartInAutoMode ) SpeedRegMode = SpeedRegulatorMode . Auto ;
412412 }
413413
414414 private void ComputeNumberOfAxles ( )
@@ -511,8 +511,8 @@ public void Update(float elapsedClockSeconds)
511511 CCThrottleOrDynBrakePercent = 0 ;
512512 trainBrakePercent = 0 ;
513513 }
514- else if ( ( Locomotive . TrainBrakeController . MaxPressurePSI - Locomotive . BrakeSystem . BrakeLine1PressurePSI > 1 || Locomotive . Train . BrakeLine4 > 0 )
515- && ! CCIsUsingTrainBrake )
514+ else if ( ( Locomotive . TrainBrakeController . MaxPressurePSI - Locomotive . BrakeSystem . BrakeLine1PressurePSI > 1 ||
515+ Locomotive . Train . BrakeLine4 > 0 && TrainBrakePriority ) && ! CCIsUsingTrainBrake )
516516 {
517517 reducingForce = true ;
518518 timeFromEngineMoved = 0 ;
@@ -638,6 +638,11 @@ public void SpeedRegulatorModeIncrease()
638638 if ( SpeedRegulatorOptions . Contains ( "regulatorauto" ) ) test = true ;
639639 if ( ! DisableManualSwitchToAutoWhenSetSpeedNotAtTop && ! KeepSelectedSpeedWhenManualModeSet ) SelectedSpeedMpS = Locomotive . AbsSpeedMpS ;
640640 if ( UseThrottleAsForceSelector && ModeSwitchAllowedWithThrottleNotAtZero ) SelectedMaxAccelerationPercent = Locomotive . ThrottleController . CurrentValue * 100 ;
641+ if ( UseThrottleAsSpeedSelector && ModeSwitchAllowedWithThrottleNotAtZero )
642+ {
643+ SelectedSpeedMpS = Locomotive . ThrottleController . CurrentValue * Locomotive . MaxSpeedMpS ;
644+ SelectedMaxAccelerationPercent = 100 ;
645+ }
641646 break ;
642647 }
643648 case SpeedRegulatorMode . Testing : if ( SpeedRegulatorOptions . Contains ( "regulatortest" ) ) test = true ; break ;
@@ -655,7 +660,8 @@ public void SpeedRegulatorModeDecrease()
655660 Locomotive . SignalEvent ( Common . Event . CruiseControlSpeedRegulator ) ;
656661 if ( SpeedRegMode == SpeedRegulatorMode . Manual ) return ;
657662 if ( SpeedRegMode == SpeedRegulatorMode . Auto &&
658- ( ! ModeSwitchAllowedWithThrottleNotAtZero && SelectedMaxAccelerationPercent != 0 ) )
663+ ! ModeSwitchAllowedWithThrottleNotAtZero &&
664+ ( SelectedMaxAccelerationPercent != 0 && ! UseThrottleAsSpeedSelector || SelectedSpeedMpS > 0 && UseThrottleAsSpeedSelector ) )
659665 return ;
660666 bool test = false ;
661667 while ( ! test )
@@ -666,6 +672,16 @@ public void SpeedRegulatorModeDecrease()
666672 case SpeedRegulatorMode . Auto : if ( SpeedRegulatorOptions . Contains ( "regulatorauto" ) ) test = true ; break ;
667673 case SpeedRegulatorMode . Manual :
668674 {
675+ if ( UseThrottleAsSpeedSelector && ModeSwitchAllowedWithThrottleNotAtZero )
676+ {
677+ Locomotive . ThrottleController . SetPercent ( SelectedSpeedMpS / Locomotive . MaxSpeedMpS * 100 ) ;
678+ if ( SelectedSpeedMpS > 0 ) Locomotive . DynamicBrakeController . SetPercent ( - 1 ) ;
679+ }
680+ if ( UseThrottleAsForceSelector && ModeSwitchAllowedWithThrottleNotAtZero )
681+ {
682+ Locomotive . ThrottleController . SetPercent ( SelectedMaxAccelerationPercent ) ;
683+ if ( SelectedMaxAccelerationPercent > 0 ) Locomotive . DynamicBrakeController . SetPercent ( - 1 ) ;
684+ }
669685 if ( ! ModeSwitchAllowedWithThrottleNotAtZero )
670686 Locomotive . ThrottleController . SetPercent ( 0 ) ;
671687 if ( SpeedRegulatorOptions . Contains ( "regulatormanual" ) ) test = true ;
@@ -783,7 +799,8 @@ protected void SpeedRegulatorMaxForceIncrease(float elapsedClockSeconds)
783799 return ;
784800 speedRegulatorIntermediateValue += StepSize * elapsedClockSeconds ;
785801 selectedMaxAccelerationPercent = Math . Min ( ( float ) Math . Truncate ( speedRegulatorIntermediateValue + 1 ) , 100 ) ;
786- if ( UseThrottleAsForceSelector && ModeSwitchAllowedWithThrottleNotAtZero && ! UseThrottleInCombinedControl )
802+ if ( UseThrottleAsForceSelector && ModeSwitchAllowedWithThrottleNotAtZero &&
803+ ( Locomotive . CombinedControlType == MSTSLocomotive . CombinedControl . ThrottleDynamic && ! Locomotive . DynamicBrake ) )
787804 Locomotive . ThrottleController . SetPercent ( selectedMaxAccelerationPercent ) ;
788805 }
789806 else
@@ -792,7 +809,8 @@ protected void SpeedRegulatorMaxForceIncrease(float elapsedClockSeconds)
792809 return ;
793810 speedRegulatorIntermediateValue += MaxForceSelectorIsDiscrete ? elapsedClockSeconds : StepSize * elapsedClockSeconds * SpeedRegulatorMaxForceSteps / 100.0f ;
794811 selectedMaxAccelerationStep = Math . Min ( ( float ) Math . Truncate ( speedRegulatorIntermediateValue + 1 ) , SpeedRegulatorMaxForceSteps ) ;
795- if ( UseThrottleAsForceSelector && ModeSwitchAllowedWithThrottleNotAtZero && ! UseThrottleInCombinedControl )
812+ if ( UseThrottleAsForceSelector && ModeSwitchAllowedWithThrottleNotAtZero &&
813+ ( Locomotive . CombinedControlType == MSTSLocomotive . CombinedControl . ThrottleDynamic && ! Locomotive . DynamicBrake ) )
796814 Locomotive . ThrottleController . SetPercent ( selectedMaxAccelerationStep * 100 / SpeedRegulatorMaxForceSteps ) ;
797815 }
798816 Simulator . Confirmer . ConfirmWithPerCent ( CabControl . MaxAcceleration , SelectedMaxAccelerationPercent ) ;
@@ -819,7 +837,8 @@ protected void SpeedRegulatorMaxForceDecrease(float elapsedClockSeconds)
819837 return ;
820838 speedRegulatorIntermediateValue -= StepSize * elapsedClockSeconds ;
821839 selectedMaxAccelerationPercent = Math . Max ( ( int ) speedRegulatorIntermediateValue , 100 ) ;
822- if ( UseThrottleAsForceSelector && ModeSwitchAllowedWithThrottleNotAtZero && ! UseThrottleInCombinedControl )
840+ if ( UseThrottleAsForceSelector && ModeSwitchAllowedWithThrottleNotAtZero &&
841+ ( Locomotive . CombinedControlType == MSTSLocomotive . CombinedControl . ThrottleDynamic && ! Locomotive . DynamicBrake ) )
823842 Locomotive . ThrottleController . SetPercent ( selectedMaxAccelerationPercent ) ;
824843 if ( selectedMaxAccelerationPercent == 0 )
825844 {
@@ -833,7 +852,8 @@ protected void SpeedRegulatorMaxForceDecrease(float elapsedClockSeconds)
833852 return ;
834853 speedRegulatorIntermediateValue -= MaxForceSelectorIsDiscrete ? elapsedClockSeconds : StepSize * elapsedClockSeconds * SpeedRegulatorMaxForceSteps / 100.0f ;
835854 selectedMaxAccelerationStep = Math . Max ( ( int ) speedRegulatorIntermediateValue , DisableZeroForceStep ? 1 : 0 ) ;
836- if ( UseThrottleAsForceSelector && ModeSwitchAllowedWithThrottleNotAtZero && ! UseThrottleInCombinedControl )
855+ if ( UseThrottleAsForceSelector && ModeSwitchAllowedWithThrottleNotAtZero &&
856+ ( Locomotive . CombinedControlType == MSTSLocomotive . CombinedControl . ThrottleDynamic && ! Locomotive . DynamicBrake ) )
837857 Locomotive . ThrottleController . SetPercent ( selectedMaxAccelerationStep * 100 / SpeedRegulatorMaxForceSteps ) ;
838858 if ( selectedMaxAccelerationStep <= ( DisableZeroForceStep ? 1 : 0 ) )
839859 {
@@ -867,7 +887,8 @@ public void SpeedRegulatorMaxForceChangeByMouse(float movExtension, float maxVal
867887 {
868888 selectedMaxAccelerationPercent += movExtension * maxValue ;
869889 selectedMaxAccelerationPercent = MathHelper . Clamp ( selectedMaxAccelerationPercent , 0 , 100 ) ;
870- if ( UseThrottleAsForceSelector && ModeSwitchAllowedWithThrottleNotAtZero && ! UseThrottleInCombinedControl )
890+ if ( UseThrottleAsForceSelector && ModeSwitchAllowedWithThrottleNotAtZero &&
891+ ( Locomotive . CombinedControlType == MSTSLocomotive . CombinedControl . ThrottleDynamic && ! Locomotive . DynamicBrake ) )
871892 Locomotive . ThrottleController . SetPercent ( selectedMaxAccelerationPercent ) ;
872893 if ( selectedMaxAccelerationPercent == 0 )
873894 {
@@ -889,7 +910,8 @@ public void SpeedRegulatorMaxForceChangeByMouse(float movExtension, float maxVal
889910 {
890911 selectedMaxAccelerationStep += movExtension * maxValue ;
891912 selectedMaxAccelerationStep = MathHelper . Clamp ( selectedMaxAccelerationStep , DisableZeroForceStep ? 1 : 0 , SpeedRegulatorMaxForceSteps ) ;
892- if ( UseThrottleAsForceSelector && ModeSwitchAllowedWithThrottleNotAtZero && ! UseThrottleInCombinedControl )
913+ if ( UseThrottleAsForceSelector && ModeSwitchAllowedWithThrottleNotAtZero &&
914+ ( Locomotive . CombinedControlType == MSTSLocomotive . CombinedControl . ThrottleDynamic && ! Locomotive . DynamicBrake ) )
893915 Locomotive . ThrottleController . SetPercent ( selectedMaxAccelerationStep * 100 / SpeedRegulatorMaxForceSteps ) ;
894916 if ( selectedMaxAccelerationStep == ( DisableZeroForceStep ? 1 : 0 ) )
895917 {
@@ -931,7 +953,7 @@ public void SpeedRegulatorSelectedSpeedStartIncrease()
931953 {
932954 SpeedRegMode = SpeedRegulatorMode . Auto ;
933955 }
934- if ( UseThrottleAsSpeedSelector || HasProportionalSpeedSelector )
956+ if ( UseThrottleAsSpeedSelector || HasProportionalSpeedSelector || ( UseThrottleAsForceSelector && mpc == null ) )
935957 {
936958 selectedSpeedIncreasing = true ;
937959 if ( SelectedSpeedMpS == 0 )
@@ -951,7 +973,7 @@ public void SpeedRegulatorSelectedSpeedStopIncrease()
951973 mpc . DoMovement ( Controllers . MultiPositionController . Movement . Neutral ) ;
952974 return ;
953975 }
954- if ( UseThrottleAsSpeedSelector || HasProportionalSpeedSelector )
976+ if ( UseThrottleAsSpeedSelector || HasProportionalSpeedSelector || ( UseThrottleAsForceSelector && mpc == null ) )
955977 selectedSpeedIncreasing = false ;
956978 else
957979 SpeedSelectorModeStopIncrease ( ) ;
@@ -967,6 +989,8 @@ public void SpeedRegulatorSelectedSpeedIncrease()
967989 SelectedSpeedMpS = Math . Max ( MinimumSpeedForCCEffectMpS , SelectedSpeedMpS + SpeedRegulatorNominalSpeedStepMpS ) ;
968990 if ( SelectedSpeedMpS > Locomotive . MaxSpeedMpS )
969991 SelectedSpeedMpS = Locomotive . MaxSpeedMpS ;
992+ if ( SpeedRegMode == SpeedRegulatorMode . Auto && UseThrottleAsSpeedSelector && ModeSwitchAllowedWithThrottleNotAtZero )
993+ Locomotive . ThrottleController . SetPercent ( SelectedSpeedMpS / Locomotive . MaxSpeedMpS * 100 ) ;
970994 if ( SpeedIsMph )
971995 Simulator . Confirmer . Message ( ConfirmLevel . Information , Simulator . Catalog . GetStringFmt ( "Selected speed changed to {0} mph" , Math . Round ( MpS . FromMpS ( SelectedSpeedMpS , false ) , 0 , MidpointRounding . AwayFromZero ) . ToString ( ) ) ) ;
972996 else
@@ -983,7 +1007,7 @@ public void SpeedRegulatorSelectedSpeedStartDecrease()
9831007 mpc . DoMovement ( Controllers . MultiPositionController . Movement . Aft ) ;
9841008 return ;
9851009 }
986- if ( UseThrottleAsSpeedSelector || HasProportionalSpeedSelector )
1010+ if ( UseThrottleAsSpeedSelector || HasProportionalSpeedSelector || ( UseThrottleAsForceSelector && mpc == null ) )
9871011 SelectedSpeedDecreasing = true ;
9881012 else
9891013 SpeedSelectorModeDecrease ( ) ;
@@ -1011,6 +1035,8 @@ public void SpeedRegulatorSelectedSpeedDecrease()
10111035 SelectedSpeedMpS = 0f ;
10121036 if ( MinimumSpeedForCCEffectMpS > 0 && SelectedSpeedMpS < MinimumSpeedForCCEffectMpS )
10131037 SelectedSpeedMpS = 0 ;
1038+ if ( SpeedRegMode == SpeedRegulatorMode . Auto && UseThrottleAsSpeedSelector && ModeSwitchAllowedWithThrottleNotAtZero )
1039+ Locomotive . ThrottleController . SetPercent ( SelectedSpeedMpS / Locomotive . MaxSpeedMpS * 100 ) ;
10141040 if ( SpeedRegMode == SpeedRegulatorMode . Auto && ForceRegulatorAutoWhenNonZeroSpeedSelected && SelectedSpeedMpS == 0 )
10151041 {
10161042 // return back to manual, clear all we have controlled before and let the driver to set up new stuff
@@ -1065,6 +1091,8 @@ public void SpeedRegulatorSelectedSpeedChangeByMouse(float movExtension, bool me
10651091 SelectedSpeedMpS = Locomotive . MaxSpeedMpS ;
10661092 if ( SelectedSpeedMpS < 0 )
10671093 SelectedSpeedMpS = 0 ;
1094+ if ( SpeedRegMode == SpeedRegulatorMode . Auto && UseThrottleAsSpeedSelector && ModeSwitchAllowedWithThrottleNotAtZero )
1095+ Locomotive . ThrottleController . SetPercent ( SelectedSpeedMpS / Locomotive . MaxSpeedMpS * 100 ) ;
10681096 if ( SelectedSpeedMpS == 0 && movExtension < 0 )
10691097 {
10701098 Locomotive . SignalEvent ( Common . Event . LeverToZero ) ;
0 commit comments