Skip to content

Commit 8773ee5

Browse files
authored
Merge pull request #1035 from mbm-OR/bugfix/Fix-TrainDrivingInfo-EngineBrakeStatus
Fix: TrainDrivingInfo crashes if engineBrakeStatus is null.
2 parents 7a341e1 + 36dcea4 commit 8773ee5

File tree

1 file changed

+22
-19
lines changed

1 file changed

+22
-19
lines changed

Source/RunActivity/Viewer3D/Popups/TrainDrivingWindow.cs

+22-19
Original file line numberDiff line numberDiff line change
@@ -1009,28 +1009,31 @@ void AddSeparator() => AddLabel(new ListLabel
10091009
});
10101010
}
10111011

1012-
if (engineBrakeStatus.Contains(Viewer.Catalog.GetString("BC")))
1012+
if (engineBrakeStatus != null)
10131013
{
1014-
AddLabel(new ListLabel
1015-
{
1016-
FirstCol = Viewer.Catalog.GetString("Engine brake"),
1017-
LastCol = engineBrakeStatus.Substring(0, engineBrakeStatus.IndexOf("BC")) + ColorCode[Color.Cyan],
1018-
});
1019-
index = engineBrakeStatus.IndexOf(Viewer.Catalog.GetString("BC"));
1020-
brakeInfoValue = engineBrakeStatus.Substring(index, engineBrakeStatus.Length - index).TrimEnd();
1021-
AddLabel(new ListLabel
1014+
if (engineBrakeStatus.Contains(Viewer.Catalog.GetString("BC")))
10221015
{
1023-
FirstCol = Viewer.Catalog.GetString(""),
1024-
LastCol = $"{brakeInfoValue}{ColorCode[Color.White]}",
1025-
});
1026-
}
1027-
else
1028-
{
1029-
AddLabel(new ListLabel
1016+
AddLabel(new ListLabel
1017+
{
1018+
FirstCol = Viewer.Catalog.GetString("Engine brake"),
1019+
LastCol = engineBrakeStatus.Substring(0, engineBrakeStatus.IndexOf("BC")) + ColorCode[Color.Cyan],
1020+
});
1021+
index = engineBrakeStatus.IndexOf(Viewer.Catalog.GetString("BC"));
1022+
brakeInfoValue = engineBrakeStatus.Substring(index, engineBrakeStatus.Length - index).TrimEnd();
1023+
AddLabel(new ListLabel
1024+
{
1025+
FirstCol = Viewer.Catalog.GetString(""),
1026+
LastCol = $"{brakeInfoValue}{ColorCode[Color.White]}",
1027+
});
1028+
}
1029+
else
10301030
{
1031-
FirstCol = Viewer.Catalog.GetString("Engine brake"),
1032-
LastCol = $"{engineBrakeStatus}{ColorCode[Color.Cyan]}",
1033-
});
1031+
AddLabel(new ListLabel
1032+
{
1033+
FirstCol = Viewer.Catalog.GetString("Engine brake"),
1034+
LastCol = $"{engineBrakeStatus}{ColorCode[Color.Cyan]}",
1035+
});
1036+
}
10341037
}
10351038

10361039
if (dynamicBrakeStatus != null && locomotive.IsLeadLocomotive())

0 commit comments

Comments
 (0)