From d7d0463c948f892c861c9e1526535a813ce18904 Mon Sep 17 00:00:00 2001 From: Chomp Date: Mon, 2 Jun 2025 11:26:20 +0100 Subject: [PATCH] Replaced direct key access with `TryAdd` --- .../Services/BotLootCacheService.cs | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/Libraries/SPTarkov.Server.Core/Services/BotLootCacheService.cs b/Libraries/SPTarkov.Server.Core/Services/BotLootCacheService.cs index b10a0347..00596e36 100644 --- a/Libraries/SPTarkov.Server.Core/Services/BotLootCacheService.cs +++ b/Libraries/SPTarkov.Server.Core/Services/BotLootCacheService.cs @@ -241,7 +241,7 @@ public class BotLootCacheService( var itemTemplate = _itemHelper.GetItem(itemKvP.Key).Value; if (!(IsBulletOrGrenade(itemTemplate.Properties) || IsMagazine(itemTemplate.Properties))) { - specialLootItems[itemKvP.Key] = itemKvP.Value; + specialLootItems.TryAdd(itemKvP.Key, itemKvP.Value); } } } @@ -265,7 +265,7 @@ public class BotLootCacheService( itemTemplate.Parent != BaseClasses.DRUGS ) { - healingItems[itemKvP.Key] = itemKvP.Value; + healingItems.TryAdd(itemKvP.Key, itemKvP.Value); } } } @@ -286,7 +286,7 @@ public class BotLootCacheService( lock (_drugLock) { - drugItems[itemKvP.Key] = itemKvP.Value; + drugItems.TryAdd(itemKvP.Key, itemKvP.Value); } } } @@ -307,7 +307,7 @@ public class BotLootCacheService( lock (_foodLock) { - foodItems[itemKvP.Key] = itemKvP.Value; + foodItems.TryAdd(itemKvP.Key, itemKvP.Value); } } } @@ -328,7 +328,7 @@ public class BotLootCacheService( lock (_drinkLock) { - drinkItems[itemKvP.Key] = itemKvP.Value; + drinkItems.TryAdd(itemKvP.Key, itemKvP.Value); } } } @@ -348,7 +348,7 @@ public class BotLootCacheService( lock (_currencyLock) { - currencyItems[itemKvP.Key] = itemKvP.Value; + currencyItems.TryAdd(itemKvP.Key, itemKvP.Value); } } } @@ -368,7 +368,7 @@ public class BotLootCacheService( lock (_stimLock) { - stimItems[itemKvP.Key] = itemKvP.Value; + stimItems.TryAdd(itemKvP.Key, itemKvP.Value); } } } @@ -388,7 +388,7 @@ public class BotLootCacheService( lock (_grenadeLock) { - grenadeItems[itemKvP.Key] = itemKvP.Value; + grenadeItems.TryAdd(itemKvP.Key, itemKvP.Value); } } }