Skip to content

Commit

Permalink
Prevent exception when loading CK3 culture with unrecognized heritage (
Browse files Browse the repository at this point in the history
  • Loading branch information
IhateTrains authored Oct 6, 2023
1 parent 672b14d commit acba752
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion ImperatorToCK3/CK3/Cultures/CultureCollection.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,10 @@ private void InitCultureDataParser(ColorFactory colorFactory) {
});
cultureDataParser.RegisterKeyword("heritage", reader => {
var heritageId = reader.GetString();
cultureData.Heritage = pillarCollection.Heritages.First(p => p.Id == heritageId);
cultureData.Heritage = pillarCollection.Heritages.FirstOrDefault(p => p.Id == heritageId);
if (cultureData.Heritage is null) {
Logger.Warn($"Found unrecognized heritage when parsing cultures: {heritageId}");
}
});
cultureDataParser.RegisterKeyword("traditions", reader => {
cultureData.TraditionIds = reader.GetStrings().ToOrderedSet();
Expand Down

0 comments on commit acba752

Please sign in to comment.