Skip to content

Commit 722037c

Browse files
committed
Fix possibility for a null reference exception to occur after uncoupling
1 parent 11ac52c commit 722037c

File tree

1 file changed

+4
-4
lines changed
  • Source/Orts.Simulation/Simulation/RollingStocks/SubSystems/Brakes/MSTS

1 file changed

+4
-4
lines changed

Source/Orts.Simulation/Simulation/RollingStocks/SubSystems/Brakes/MSTS/AirSinglePipe.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1217,9 +1217,9 @@ protected static void PropagateBrakeLinePressures(float elapsedClockSeconds, Tra
12171217
{
12181218
// Only sync application/release on DP units if both the lead unit AND the DP lead unit are set to synchronize
12191219
// Lead locomotive will always be allowed to apply/release
1220-
bool syncApplication = loco == lead ? true : loco.DPSyncTrainApplication && lead.DPSyncTrainApplication;
1221-
bool syncRelease = loco == lead ? true : loco.DPSyncTrainRelease && lead.DPSyncTrainRelease;
1222-
bool syncEmergency = loco == lead ? true : loco.DPSyncEmergency && lead.DPSyncEmergency;
1220+
bool syncApplication = loco == lead || loco.DPSyncTrainApplication && lead.DPSyncTrainApplication;
1221+
bool syncRelease = loco == lead || loco.DPSyncTrainRelease && lead.DPSyncTrainRelease;
1222+
bool syncEmergency = loco == lead || loco.DPSyncEmergency && lead.DPSyncEmergency;
12231223

12241224
tempBrakePipeFlow = 0.0f;
12251225

@@ -1445,7 +1445,7 @@ protected static void PropagateBrakeLinePressures(float elapsedClockSeconds, Tra
14451445
MSTSLocomotive leadLoco = train.DPLeadUnits[i] as MSTSLocomotive;
14461446
BrakeSystem locoBrakeSystem = train.DPLeadUnits[i].BrakeSystem;
14471447

1448-
bool syncIndependent = leadLoco == lead ? true : leadLoco.DPSyncIndependent && lead.DPSyncIndependent;
1448+
bool syncIndependent = lead != null && (leadLoco == lead || (leadLoco.DPSyncIndependent && lead.DPSyncIndependent));
14491449

14501450
// Set loco brake pressure on all units with brakes cut in
14511451
// Only set loco brake pressure on DP units if lead loco AND DP loco are equipped to synchronize braking

0 commit comments

Comments
 (0)