From 2ae91b4c3887de2592064ca01b3fa014db76e950 Mon Sep 17 00:00:00 2001 From: Chomp Date: Mon, 2 Jun 2025 16:09:39 +0100 Subject: [PATCH] Added safer dictionary access inside `GetLootFromCache` --- .../Services/BotLootCacheService.cs | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/Libraries/SPTarkov.Server.Core/Services/BotLootCacheService.cs b/Libraries/SPTarkov.Server.Core/Services/BotLootCacheService.cs index a487a960..09cd4890 100644 --- a/Libraries/SPTarkov.Server.Core/Services/BotLootCacheService.cs +++ b/Libraries/SPTarkov.Server.Core/Services/BotLootCacheService.cs @@ -62,11 +62,13 @@ public class BotLootCacheService( AddLootToCache(botRole, isPmc, botJsonTemplate); } + if(!_lootCache.TryGetValue(botRole, out var botRoleCache)) + { + _logger.Error($"Unable to find: {botRole} in loot cache"); + return []; + } + Dictionary result = null; - BotLootCache botRoleCache; - - botRoleCache = _lootCache[botRole]; - switch (lootType) { case LootCacheType.Special: