From fd3b0c0ead5f1feb428ff24c4b95f9ef92eeb195 Mon Sep 17 00:00:00 2001 From: Chomp Date: Mon, 2 Jun 2025 11:28:58 +0100 Subject: [PATCH] Replaced direct key access with `TryAdd` --- .../Services/BotLootCacheService.cs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/Libraries/SPTarkov.Server.Core/Services/BotLootCacheService.cs b/Libraries/SPTarkov.Server.Core/Services/BotLootCacheService.cs index 00596e36..24c9ff60 100644 --- a/Libraries/SPTarkov.Server.Core/Services/BotLootCacheService.cs +++ b/Libraries/SPTarkov.Server.Core/Services/BotLootCacheService.cs @@ -418,7 +418,7 @@ public class BotLootCacheService( continue; } - filteredBackpackItems[itemKvP.Key] = itemKvP.Value; + filteredBackpackItems.TryAdd(itemKvP.Key, itemKvP.Value); } // Get pocket loot (excluding magazines, bullets, grenades, drink, food medical and healing/stim items) @@ -447,7 +447,7 @@ public class BotLootCacheService( continue; } - filteredPocketItems[itemKvP.Key] = itemKvP.Value; + filteredPocketItems.TryAdd(itemKvP.Key, itemKvP.Value); } // Get vest loot (excluding magazines, bullets, grenades, medical and healing/stim items) @@ -474,7 +474,7 @@ public class BotLootCacheService( continue; } - filteredVestItems[itemKvP.Key] = itemKvP.Value; + filteredVestItems.TryAdd(itemKvP.Key, itemKvP.Value); } // Get secure loot (excluding magazines, bullets) @@ -493,7 +493,7 @@ public class BotLootCacheService( continue; } - filteredSecureLoot[itemKvP.Key] = itemKvP.Value; + filteredSecureLoot.TryAdd(itemKvP.Key, itemKvP.Value); } var cacheForRole = _lootCache[botRole]; @@ -521,7 +521,7 @@ public class BotLootCacheService( continue; } - poolToAddTo[tpl.Key] = poolOfItemsToAdd[tpl.Key]; + poolToAddTo.TryAdd(tpl.Key, poolOfItemsToAdd[tpl.Key]); } }