Skip to content

Commit e7de35f

Browse files
committed
Fix null references when attempting to use dynamic brake keybinds with no dynamic brake controller
1 parent de1bccb commit e7de35f

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4731,7 +4731,7 @@ public void StartDynamicBrakeIncrease(float? target)
47314731
return;
47324732

47334733
// Only allow increasing dynamic brake if dynamic braking is off, there's no setup lock, or dynamic braking is already active
4734-
if (DynamicBrake || !DynamicBrakeControllerSetupLock || DynamicBrakeController.CurrentValue <= 0)
4734+
if (DynamicBrakeController != null && (DynamicBrake || !DynamicBrakeControllerSetupLock || DynamicBrakeController.CurrentValue <= 0))
47354735
{
47364736
float prevValue = DynamicBrakeController.CurrentValue;
47374737

@@ -4767,7 +4767,7 @@ public void StartDynamicBrakeDecrease(float? target)
47674767
{
47684768
// Only allow decreasing dynamic brake if dynamic brake isn't off
47694769
// Note: For safety, this will allow decreasing the dynamic brake even if a mechanical interlock should have locked dynamic brake in off position
4770-
if (DynamicBrakeController.CurrentValue > 0)
4770+
if (DynamicBrakeController?.CurrentValue > 0)
47714771
{
47724772
DynamicBrakeController.StartDecrease(target);
47734773

@@ -4878,7 +4878,7 @@ public void SetDynamicBrakePercentWithSound(float percent)
48784878
public bool CheckDisableDynamicBrake()
48794879
{
48804880
// Only disable the dynamic brake if the lever is in the off position and the controller isn't trying to increase
4881-
if (DynamicBrakeController.CurrentValue <= 0 && DynamicBrakeController.UpdateValue <= 0)
4881+
if (DynamicBrakeController?.CurrentValue <= 0 && DynamicBrakeController?.UpdateValue <= 0)
48824882
{
48834883
StopDynamicBrakeDecrease();
48844884
Simulator.Confirmer.Confirm(CabControl.DynamicBrake, CabSetting.Off);

0 commit comments

Comments
 (0)