Skip to content

Commit 13230d5

Browse files
committed
Allow discrete speeds even when using throttle as speed selector
1 parent ac323a2 commit 13230d5

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

Source/Orts.Simulation/Simulation/RollingStocks/SubSystems/CruiseControl.cs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -252,7 +252,6 @@ public CruiseControl(CruiseControl other, MSTSLocomotive locomotive)
252252
SpeedRegulatorOptions = other.SpeedRegulatorOptions;
253253
CruiseControlLogic = other.CruiseControlLogic;
254254
SpeedDeltaFunctionMode = other.SpeedDeltaFunctionMode;
255-
SpeedRegulatorNominalSpeedStepMpS = other.SpeedRegulatorNominalSpeedStepMpS;
256255
MaxAccelerationMpSS = other.MaxAccelerationMpSS;
257256
MaxDecelerationMpSS = other.MaxDecelerationMpSS;
258257
StartReducingSpeedDelta = other.StartReducingSpeedDelta;
@@ -1541,7 +1540,12 @@ protected float ControllerValueToSelectedSpeedMpS(float val)
15411540
return 0;
15421541
float min = MinimumSpeedForCCEffectMpS;
15431542
float max = Locomotive.MaxSpeedMpS;
1544-
return val * (max - min) + min;
1543+
float speed = val * (max - min) + min;
1544+
if (SpeedSelectorIsDiscrete && SpeedRegulatorNominalSpeedStepMpS > 0)
1545+
{
1546+
speed = (int)(speed / SpeedRegulatorNominalSpeedStepMpS) * SpeedRegulatorNominalSpeedStepMpS;
1547+
}
1548+
return speed;
15451549
}
15461550

15471551
public string GetCruiseControlStatus()

0 commit comments

Comments
 (0)