From 6f18ded7ce9d651ee1fdb9acd582b8e9d97ca171 Mon Sep 17 00:00:00 2001 From: IhateTrains Date: Wed, 10 Apr 2024 16:26:33 +0200 Subject: [PATCH] Prevent missing religious head character from causing an exception (#1868) #patch Sentry event ID: ee005e56b7434ce4925e015ef458982c --- ImperatorToCK3/CK3/Religions/ReligionCollection.cs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/ImperatorToCK3/CK3/Religions/ReligionCollection.cs b/ImperatorToCK3/CK3/Religions/ReligionCollection.cs index f39ce976c..fcc45f39a 100644 --- a/ImperatorToCK3/CK3/Religions/ReligionCollection.cs +++ b/ImperatorToCK3/CK3/Religions/ReligionCollection.cs @@ -319,7 +319,11 @@ Date date } var holderId = title.GetHolderId(date); if (holderId != "0") { - var holder = characters[holderId]; + if (!characters.TryGetValue(holderId, out var holder)) { + Logger.Warn($"Religious head {holderId} of title {title.Id} for {faith.Id} not found!"); + return; + } + var holderDeathDate = holder.DeathDate; if (holderDeathDate is null || holderDeathDate > date) { return;