Skip to content

Commit 343c792

Browse files
committed
Additional null check just in case
1 parent cd5c185 commit 343c792

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

Source/RunActivity/Viewer3D/Lights.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -347,7 +347,7 @@ bool UpdateState()
347347
bool newLeftDoorOpen = !Car.Lights.IgnoredConditions[11] && Car.Train?.DoorState(DoorSide.Left) != DoorState.Closed;
348348
bool newRightDoorOpen = !Car.Lights.IgnoredConditions[11] && Car.Train?.DoorState(DoorSide.Right) != DoorState.Closed;
349349
// AI trains don't have a lead locomotive, but the upcoming lighting calculations want a lead locomotive, try to determine a lead locomotive to use
350-
if (leadLocomotive == null)
350+
if (leadLocomotive == null && Car.Train != null)
351351
{
352352
// If first car is flipped, the 'lead' vehicle is actually at the rear
353353
if (Car.Train.FirstCar.Flipped && Car.Train.LastCar is MSTSLocomotive)

0 commit comments

Comments
 (0)