From d10238b0067505865520dc272be95fd6895ccc17 Mon Sep 17 00:00:00 2001 From: CWX Date: Mon, 7 Apr 2025 13:29:49 +0100 Subject: [PATCH] Check Enum has key before trying getValue --- .../SPTarkov.Server.Core/Controllers/HealthController.cs | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/Libraries/SPTarkov.Server.Core/Controllers/HealthController.cs b/Libraries/SPTarkov.Server.Core/Controllers/HealthController.cs index 8ab8af08..09a9c4d1 100644 --- a/Libraries/SPTarkov.Server.Core/Controllers/HealthController.cs +++ b/Libraries/SPTarkov.Server.Core/Controllers/HealthController.cs @@ -97,8 +97,15 @@ public class HealthController( // Can remove effects and limb has effects to remove foreach (var effectKvP in bodyPartToHeal.Effects) { + // Check enum has effectType + if (!Enum.TryParse(effectKvP.Key, out var effect)) + // Enum doesnt contain this key + { + continue; + } + // Check if healing item removes the effect on limb - if (!healItemEffectDetails.TryGetValue(Enum.Parse(effectKvP.Key), out var matchingEffectFromHealingItem)) + if (!healItemEffectDetails.TryGetValue(effect, out var matchingEffectFromHealingItem)) // Healing item doesn't have matching effect, it doesn't remove the effect { continue;