Skip to content

Commit b20ca94

Browse files
committed
Clean up first/last car check
1 parent 729e0b7 commit b20ca94

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

Source/RunActivity/Viewer3D/Lights.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -292,8 +292,8 @@ bool UpdateState()
292292
bool locomotiveFlipped = leadLocomotiveCar != null && leadLocomotiveCar.Flipped;
293293
bool locomotiveReverseCab = leadLocomotive != null && leadLocomotive.UsingRearCab;
294294
bool newCarIsReversed = Car.Flipped ^ locomotiveFlipped ^ locomotiveReverseCab;
295-
bool newCarIsFirst = !Car.Lights.IgnoredConditions[1] && Car.Train == null || (locomotiveFlipped ^ locomotiveReverseCab ? Car.Train.LastCar : Car.Train.FirstCar) == Car;
296-
bool newCarIsLast = !Car.Lights.IgnoredConditions[1] && Car.Train == null || (locomotiveFlipped ^ locomotiveReverseCab ? Car.Train.FirstCar : Car.Train.LastCar) == Car;
295+
bool newCarIsFirst = !Car.Lights.IgnoredConditions[1] && (locomotiveFlipped ^ locomotiveReverseCab ? Car.Train?.LastCar : Car.Train?.FirstCar) == Car;
296+
bool newCarIsLast = !Car.Lights.IgnoredConditions[1] && (locomotiveFlipped ^ locomotiveReverseCab ? Car.Train?.FirstCar : Car.Train?.LastCar) == Car;
297297
// Penalty
298298
bool newPenalty = !Car.Lights.IgnoredConditions[2] && leadLocomotive != null && leadLocomotive.TrainBrakeController.EmergencyBraking;
299299
// Control

0 commit comments

Comments
 (0)