Skip to content

Commit

Permalink
Prevent exception when history/province_mapping contains wrong target (
Browse files Browse the repository at this point in the history
…#1938) #patch

Sentry event ID: 4ae7df9d0cc0423184c1b132a5583ed2
  • Loading branch information
IhateTrains authored May 6, 2024
1 parent 00112fd commit 3ce404e
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions ImperatorToCK3/CK3/Provinces/ProvinceCollection.cs
Original file line number Diff line number Diff line change
Expand Up @@ -85,12 +85,17 @@ public void ImportVanillaProvinces(ModFilesystem ck3ModFs) {
// Now load the provinces that don't have unique entries in history/provinces.
// They instead use history/province_mapping.
foreach (var (newProvinceId, baseProvinceId) in new ProvinceMappings(ck3ModFs)) {
if (!ContainsKey(baseProvinceId)) {
if (!TryGetValue(baseProvinceId, out var baseProvince)) {
Logger.Warn($"Base province {baseProvinceId} not found for province {newProvinceId}.");
continue;
}

if (!TryGetValue(newProvinceId, out var newProvince)) {
Logger.Debug($"Province {newProvinceId} not found.");
continue;
}

this[newProvinceId].CopyEntriesFromProvince(this[baseProvinceId]);
newProvince.CopyEntriesFromProvince(baseProvince);
}
Logger.IncrementProgress();

Expand Down

0 comments on commit 3ce404e

Please sign in to comment.