Skip to content

Commit ea06d46

Browse files
committed
Correct display of throttle and dynamic brake with delays
1 parent 5bf4677 commit ea06d46

File tree

2 files changed

+14
-25
lines changed

2 files changed

+14
-25
lines changed

Source/Orts.Simulation/Simulation/RollingStocks/MSTSLocomotive.cs

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -4232,23 +4232,18 @@ public void StartThrottleToZero(float? target)
42324232
/// whether it is used for cruise control or not
42334233
/// </summary>
42344234
/// <param name="intermediateValue">Whather asking for intermediate (for mouse operation) or notched (for displaying) value.</param>
4235-
/// <returns>Combined position into 0-1 range</returns>
4236-
public float GetThrottleHandleValue(float data)
4235+
/// <returns>Position into 0-1 range</returns>
4236+
public float GetThrottleHandleValue(bool intermediateValue)
42374237
{
42384238
if (CruiseControl?.SpeedRegMode == CruiseControl.SpeedRegulatorMode.Auto && CruiseControl.SelectedMaxAccelerationPercent != 0
42394239
&& CruiseControl.HasIndependentThrottleDynamicBrakeLever)
4240-
return ThrottleController.CurrentValue;
4240+
return intermediateValue ? ThrottleController.CurrentValue : ThrottleController.IntermediateValue;
42414241
if (CruiseControl?.SpeedRegMode == CruiseControl.SpeedRegulatorMode.Auto && CruiseControl.UseThrottleAsForceSelector)
42424242
return CruiseControl.SelectedMaxAccelerationPercent / 100;
42434243
if (CruiseControl?.SpeedRegMode == CruiseControl.SpeedRegulatorMode.Auto && CruiseControl.UseThrottleAsSpeedSelector)
42444244
return CruiseControl.SelectedSpeedMpS / MaxSpeedMpS;
42454245

4246-
4247-
if (CruiseControl == null || CruiseControl.SpeedRegMode == CruiseControl.SpeedRegulatorMode.Manual)
4248-
return data;
4249-
else
4250-
return ThrottleController.CurrentValue;
4251-
4246+
return intermediateValue ? ThrottleController.CurrentValue : ThrottleController.IntermediateValue;
42524247
}
42534248

42544249
#endregion
@@ -5777,7 +5772,7 @@ public virtual float GetDataOf(CabViewControl cvc)
57775772
case CABViewControlTypes.THROTTLE:
57785773
{
57795774
if (CruiseControl != null && CruiseControl.SkipThrottleDisplay) break;
5780-
data = GetThrottleHandleValue((Train.TrainType == Train.TRAINTYPE.AI_PLAYERHOSTING || Train.Autopilot) ? ThrottlePercent / 100f : LocalThrottlePercent / 100f);
5775+
data = GetThrottleHandleValue(false);
57815776
break;
57825777
}
57835778
case CABViewControlTypes.THROTTLE_DISPLAY:
@@ -5872,10 +5867,13 @@ public virtual float GetDataOf(CabViewControl cvc)
58725867
break;
58735868
}
58745869
case CABViewControlTypes.DYNAMIC_BRAKE:
5870+
{
5871+
data = DynamicBrakeController?.CurrentValue ?? 0;
5872+
break;
5873+
}
58755874
case CABViewControlTypes.DYNAMIC_BRAKE_DISPLAY:
5876-
//case CABViewControlTypes.CP_HANDLE:
58775875
{
5878-
data = DynamicBrakePercent / 100f;
5876+
data = (Train.TrainType == Train.TRAINTYPE.AI_PLAYERHOSTING || Train.Autopilot) ? DynamicBrakePercent / 100 : LocalDynamicBrakePercent / 100;
58795877
break;
58805878
}
58815879
case CABViewControlTypes.WIPERS:

Source/RunActivity/Viewer3D/RollingStock/MSTSLocomotiveViewer.cs

Lines changed: 4 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2138,26 +2138,17 @@ public virtual int GetDrawIndex()
21382138
case CABViewControlTypes.FIREHOLE:
21392139
case CABViewControlTypes.THROTTLE:
21402140
case CABViewControlTypes.THROTTLE_DISPLAY:
2141+
case CABViewControlTypes.DYNAMIC_BRAKE_DISPLAY:
21412142
index = PercentToIndex(data);
21422143
break;
21432144
case CABViewControlTypes.FRICTION_BRAKING:
21442145
index = data > 0.001 ? 1 : 0;
21452146
break;
21462147
case CABViewControlTypes.DYNAMIC_BRAKE:
2147-
case CABViewControlTypes.DYNAMIC_BRAKE_DISPLAY:
2148-
var dynBrakePercent = (Locomotive.Train.TrainType == Train.TRAINTYPE.AI_PLAYERHOSTING || Locomotive.Train.Autopilot) ?
2149-
Locomotive.DynamicBrakePercent : Locomotive.LocalDynamicBrakePercent;
2150-
if (dynBrakePercent <= 0)
2151-
index = 0;
2152-
else if (Locomotive.DynamicBrakeController != null)
2153-
{
2154-
if (!Locomotive.HasSmoothStruc)
2155-
index = Locomotive.DynamicBrakeController.CurrentNotch;
2156-
else
2157-
index = PercentToIndex(Locomotive.DynamicBrakeController.CurrentValue);
2158-
}
2148+
if (Locomotive.DynamicBrakeController != null && !Locomotive.HasSmoothStruc)
2149+
index = Locomotive.DynamicBrakeController.CurrentNotch;
21592150
else
2160-
index = PercentToIndex(dynBrakePercent);
2151+
index = PercentToIndex(data);
21612152
break;
21622153
case CABViewControlTypes.CPH_DISPLAY:
21632154
case CABViewControlTypes.CP_HANDLE:

0 commit comments

Comments
 (0)