Skip to content

Commit 83de929

Browse files
authored
Avoid KeyNotFoundException during filler holder generation (#3024)
1 parent 6c02f6f commit 83de929

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

ImperatorToCK3/CK3/World.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1201,7 +1201,7 @@ private void GenerateFillerHoldersForUnownedLands(Imperator.Provinces.ProvinceCo
12011201
// This fixes stuff like a vanilla Tang China in one county.
12021202
var irProvIds = county.CountyProvinceIds
12031203
.SelectMany(id => provinceMapper.GetImperatorProvinceNumbers(id)).ToArray();
1204-
if (irProvIds.Length > 0 && irProvIds.All(p => irProvinces[p].OwnerCountry is null)) {
1204+
if (irProvIds.Length > 0 && irProvIds.All(p => !irProvinces.TryGetValue(p, out var irProv) || irProv.OwnerCountry is null)) {
12051205
Logger.Debug($"Adding {county.Id} to unheld counties because all its provinces are mapped to I:R wastelands.");
12061206
unheldCounties.Add(county);
12071207
continue;

0 commit comments

Comments
 (0)