@@ -408,7 +408,7 @@ public void Initialize()
408
408
409
409
ComputeNumberOfAxles ( ) ;
410
410
if ( StartReducingSpeedDeltaDownwards == 0 ) StartReducingSpeedDeltaDownwards = StartReducingSpeedDelta ;
411
- if ( StartInAutoMode ) SpeedRegMode = SpeedRegulatorMode . Auto ;
411
+ if ( StartInAutoMode ) SpeedRegMode = SpeedRegulatorMode . Auto ;
412
412
}
413
413
414
414
private void ComputeNumberOfAxles ( )
@@ -511,8 +511,8 @@ public void Update(float elapsedClockSeconds)
511
511
CCThrottleOrDynBrakePercent = 0 ;
512
512
trainBrakePercent = 0 ;
513
513
}
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 )
516
516
{
517
517
reducingForce = true ;
518
518
timeFromEngineMoved = 0 ;
@@ -638,6 +638,11 @@ public void SpeedRegulatorModeIncrease()
638
638
if ( SpeedRegulatorOptions . Contains ( "regulatorauto" ) ) test = true ;
639
639
if ( ! DisableManualSwitchToAutoWhenSetSpeedNotAtTop && ! KeepSelectedSpeedWhenManualModeSet ) SelectedSpeedMpS = Locomotive . AbsSpeedMpS ;
640
640
if ( UseThrottleAsForceSelector && ModeSwitchAllowedWithThrottleNotAtZero ) SelectedMaxAccelerationPercent = Locomotive . ThrottleController . CurrentValue * 100 ;
641
+ if ( UseThrottleAsSpeedSelector && ModeSwitchAllowedWithThrottleNotAtZero )
642
+ {
643
+ SelectedSpeedMpS = Locomotive . ThrottleController . CurrentValue * Locomotive . MaxSpeedMpS ;
644
+ SelectedMaxAccelerationPercent = 100 ;
645
+ }
641
646
break ;
642
647
}
643
648
case SpeedRegulatorMode . Testing : if ( SpeedRegulatorOptions . Contains ( "regulatortest" ) ) test = true ; break ;
@@ -655,7 +660,8 @@ public void SpeedRegulatorModeDecrease()
655
660
Locomotive . SignalEvent ( Common . Event . CruiseControlSpeedRegulator ) ;
656
661
if ( SpeedRegMode == SpeedRegulatorMode . Manual ) return ;
657
662
if ( SpeedRegMode == SpeedRegulatorMode . Auto &&
658
- ( ! ModeSwitchAllowedWithThrottleNotAtZero && SelectedMaxAccelerationPercent != 0 ) )
663
+ ! ModeSwitchAllowedWithThrottleNotAtZero &&
664
+ ( SelectedMaxAccelerationPercent != 0 && ! UseThrottleAsSpeedSelector || SelectedSpeedMpS > 0 && UseThrottleAsSpeedSelector ) )
659
665
return ;
660
666
bool test = false ;
661
667
while ( ! test )
@@ -666,6 +672,16 @@ public void SpeedRegulatorModeDecrease()
666
672
case SpeedRegulatorMode . Auto : if ( SpeedRegulatorOptions . Contains ( "regulatorauto" ) ) test = true ; break ;
667
673
case SpeedRegulatorMode . Manual :
668
674
{
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
+ }
669
685
if ( ! ModeSwitchAllowedWithThrottleNotAtZero )
670
686
Locomotive . ThrottleController . SetPercent ( 0 ) ;
671
687
if ( SpeedRegulatorOptions . Contains ( "regulatormanual" ) ) test = true ;
@@ -783,7 +799,8 @@ protected void SpeedRegulatorMaxForceIncrease(float elapsedClockSeconds)
783
799
return ;
784
800
speedRegulatorIntermediateValue += StepSize * elapsedClockSeconds ;
785
801
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 ) )
787
804
Locomotive . ThrottleController . SetPercent ( selectedMaxAccelerationPercent ) ;
788
805
}
789
806
else
@@ -792,7 +809,8 @@ protected void SpeedRegulatorMaxForceIncrease(float elapsedClockSeconds)
792
809
return ;
793
810
speedRegulatorIntermediateValue += MaxForceSelectorIsDiscrete ? elapsedClockSeconds : StepSize * elapsedClockSeconds * SpeedRegulatorMaxForceSteps / 100.0f ;
794
811
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 ) )
796
814
Locomotive . ThrottleController . SetPercent ( selectedMaxAccelerationStep * 100 / SpeedRegulatorMaxForceSteps ) ;
797
815
}
798
816
Simulator . Confirmer . ConfirmWithPerCent ( CabControl . MaxAcceleration , SelectedMaxAccelerationPercent ) ;
@@ -819,7 +837,8 @@ protected void SpeedRegulatorMaxForceDecrease(float elapsedClockSeconds)
819
837
return ;
820
838
speedRegulatorIntermediateValue -= StepSize * elapsedClockSeconds ;
821
839
selectedMaxAccelerationPercent = Math . Max ( ( int ) speedRegulatorIntermediateValue , 100 ) ;
822
- if ( UseThrottleAsForceSelector && ModeSwitchAllowedWithThrottleNotAtZero && ! UseThrottleInCombinedControl )
840
+ if ( UseThrottleAsForceSelector && ModeSwitchAllowedWithThrottleNotAtZero &&
841
+ ( Locomotive . CombinedControlType == MSTSLocomotive . CombinedControl . ThrottleDynamic && ! Locomotive . DynamicBrake ) )
823
842
Locomotive . ThrottleController . SetPercent ( selectedMaxAccelerationPercent ) ;
824
843
if ( selectedMaxAccelerationPercent == 0 )
825
844
{
@@ -833,7 +852,8 @@ protected void SpeedRegulatorMaxForceDecrease(float elapsedClockSeconds)
833
852
return ;
834
853
speedRegulatorIntermediateValue -= MaxForceSelectorIsDiscrete ? elapsedClockSeconds : StepSize * elapsedClockSeconds * SpeedRegulatorMaxForceSteps / 100.0f ;
835
854
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 ) )
837
857
Locomotive . ThrottleController . SetPercent ( selectedMaxAccelerationStep * 100 / SpeedRegulatorMaxForceSteps ) ;
838
858
if ( selectedMaxAccelerationStep <= ( DisableZeroForceStep ? 1 : 0 ) )
839
859
{
@@ -867,7 +887,8 @@ public void SpeedRegulatorMaxForceChangeByMouse(float movExtension, float maxVal
867
887
{
868
888
selectedMaxAccelerationPercent += movExtension * maxValue ;
869
889
selectedMaxAccelerationPercent = MathHelper . Clamp ( selectedMaxAccelerationPercent , 0 , 100 ) ;
870
- if ( UseThrottleAsForceSelector && ModeSwitchAllowedWithThrottleNotAtZero && ! UseThrottleInCombinedControl )
890
+ if ( UseThrottleAsForceSelector && ModeSwitchAllowedWithThrottleNotAtZero &&
891
+ ( Locomotive . CombinedControlType == MSTSLocomotive . CombinedControl . ThrottleDynamic && ! Locomotive . DynamicBrake ) )
871
892
Locomotive . ThrottleController . SetPercent ( selectedMaxAccelerationPercent ) ;
872
893
if ( selectedMaxAccelerationPercent == 0 )
873
894
{
@@ -889,7 +910,8 @@ public void SpeedRegulatorMaxForceChangeByMouse(float movExtension, float maxVal
889
910
{
890
911
selectedMaxAccelerationStep += movExtension * maxValue ;
891
912
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 ) )
893
915
Locomotive . ThrottleController . SetPercent ( selectedMaxAccelerationStep * 100 / SpeedRegulatorMaxForceSteps ) ;
894
916
if ( selectedMaxAccelerationStep == ( DisableZeroForceStep ? 1 : 0 ) )
895
917
{
@@ -931,7 +953,7 @@ public void SpeedRegulatorSelectedSpeedStartIncrease()
931
953
{
932
954
SpeedRegMode = SpeedRegulatorMode . Auto ;
933
955
}
934
- if ( UseThrottleAsSpeedSelector || HasProportionalSpeedSelector )
956
+ if ( UseThrottleAsSpeedSelector || HasProportionalSpeedSelector || ( UseThrottleAsForceSelector && mpc == null ) )
935
957
{
936
958
selectedSpeedIncreasing = true ;
937
959
if ( SelectedSpeedMpS == 0 )
@@ -951,7 +973,7 @@ public void SpeedRegulatorSelectedSpeedStopIncrease()
951
973
mpc . DoMovement ( Controllers . MultiPositionController . Movement . Neutral ) ;
952
974
return ;
953
975
}
954
- if ( UseThrottleAsSpeedSelector || HasProportionalSpeedSelector )
976
+ if ( UseThrottleAsSpeedSelector || HasProportionalSpeedSelector || ( UseThrottleAsForceSelector && mpc == null ) )
955
977
selectedSpeedIncreasing = false ;
956
978
else
957
979
SpeedSelectorModeStopIncrease ( ) ;
@@ -967,6 +989,8 @@ public void SpeedRegulatorSelectedSpeedIncrease()
967
989
SelectedSpeedMpS = Math . Max ( MinimumSpeedForCCEffectMpS , SelectedSpeedMpS + SpeedRegulatorNominalSpeedStepMpS ) ;
968
990
if ( SelectedSpeedMpS > Locomotive . MaxSpeedMpS )
969
991
SelectedSpeedMpS = Locomotive . MaxSpeedMpS ;
992
+ if ( SpeedRegMode == SpeedRegulatorMode . Auto && UseThrottleAsSpeedSelector && ModeSwitchAllowedWithThrottleNotAtZero )
993
+ Locomotive . ThrottleController . SetPercent ( SelectedSpeedMpS / Locomotive . MaxSpeedMpS * 100 ) ;
970
994
if ( SpeedIsMph )
971
995
Simulator . Confirmer . Message ( ConfirmLevel . Information , Simulator . Catalog . GetStringFmt ( "Selected speed changed to {0} mph" , Math . Round ( MpS . FromMpS ( SelectedSpeedMpS , false ) , 0 , MidpointRounding . AwayFromZero ) . ToString ( ) ) ) ;
972
996
else
@@ -983,7 +1007,7 @@ public void SpeedRegulatorSelectedSpeedStartDecrease()
983
1007
mpc . DoMovement ( Controllers . MultiPositionController . Movement . Aft ) ;
984
1008
return ;
985
1009
}
986
- if ( UseThrottleAsSpeedSelector || HasProportionalSpeedSelector )
1010
+ if ( UseThrottleAsSpeedSelector || HasProportionalSpeedSelector || ( UseThrottleAsForceSelector && mpc == null ) )
987
1011
SelectedSpeedDecreasing = true ;
988
1012
else
989
1013
SpeedSelectorModeDecrease ( ) ;
@@ -1011,6 +1035,8 @@ public void SpeedRegulatorSelectedSpeedDecrease()
1011
1035
SelectedSpeedMpS = 0f ;
1012
1036
if ( MinimumSpeedForCCEffectMpS > 0 && SelectedSpeedMpS < MinimumSpeedForCCEffectMpS )
1013
1037
SelectedSpeedMpS = 0 ;
1038
+ if ( SpeedRegMode == SpeedRegulatorMode . Auto && UseThrottleAsSpeedSelector && ModeSwitchAllowedWithThrottleNotAtZero )
1039
+ Locomotive . ThrottleController . SetPercent ( SelectedSpeedMpS / Locomotive . MaxSpeedMpS * 100 ) ;
1014
1040
if ( SpeedRegMode == SpeedRegulatorMode . Auto && ForceRegulatorAutoWhenNonZeroSpeedSelected && SelectedSpeedMpS == 0 )
1015
1041
{
1016
1042
// 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
1065
1091
SelectedSpeedMpS = Locomotive . MaxSpeedMpS ;
1066
1092
if ( SelectedSpeedMpS < 0 )
1067
1093
SelectedSpeedMpS = 0 ;
1094
+ if ( SpeedRegMode == SpeedRegulatorMode . Auto && UseThrottleAsSpeedSelector && ModeSwitchAllowedWithThrottleNotAtZero )
1095
+ Locomotive . ThrottleController . SetPercent ( SelectedSpeedMpS / Locomotive . MaxSpeedMpS * 100 ) ;
1068
1096
if ( SelectedSpeedMpS == 0 && movExtension < 0 )
1069
1097
{
1070
1098
Locomotive . SignalEvent ( Common . Event . LeverToZero ) ;
0 commit comments