Skip to content

Commit 75a182d

Browse files
committed
fix crash when building object has invalid heights/variations
1 parent 2f7f4f7 commit 75a182d

1 file changed

Lines changed: 6 additions & 1 deletion

File tree

Gui/ViewModels/LocoTypes/Objects/Building/BuildingComponentsViewModel.cs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,12 @@ protected void RecomputeBuildingVariationViewModels(List<List<uint8_t>> building
123123
YOffset = 0,
124124
};
125125

126-
cumulativeOffset += buildingHeights[variationItem];
126+
// this shouldn't be necessary to check, but some objects are fully invalid, eg USFIFACT, so without this
127+
// check the editor will crash but we'd instead prefer to show the invalid object to allow fixing it
128+
if (variationItem < buildingHeights.Count)
129+
{
130+
cumulativeOffset += buildingHeights[variationItem];
131+
}
127132
bs.Layers.Add(bl);
128133
}
129134
}

0 commit comments

Comments
 (0)