diff --git a/Libraries/SPTarkov.Server.Core/Services/BotLootCacheService.cs b/Libraries/SPTarkov.Server.Core/Services/BotLootCacheService.cs
index 09cd4890..a810f6da 100644
--- a/Libraries/SPTarkov.Server.Core/Services/BotLootCacheService.cs
+++ b/Libraries/SPTarkov.Server.Core/Services/BotLootCacheService.cs
@@ -40,7 +40,7 @@ public class BotLootCacheService(
}
///
- /// Get the fully created loot array, ordered by price low to high
+ /// Get a dictionary of lootable item Tpls with their corresponding weight
///
/// bot to get loot for
/// is the bot a pmc
@@ -68,7 +68,7 @@ public class BotLootCacheService(
return [];
}
- Dictionary result = null;
+ Dictionary result;
switch (lootType)
{
case LootCacheType.Special:
@@ -122,37 +122,47 @@ public class BotLootCacheService(
}
)
);
- break;
+
+ return [];
}
- if (itemPriceMinMax is not null)
+ if (!result.Any())
{
- var filteredResult = result.Where(i =>
- {
- var itemPrice = _itemHelper.GetItemPrice(i.Key);
- if (itemPriceMinMax?.Min is not null && itemPriceMinMax?.Max is not null)
- {
- return itemPrice >= itemPriceMinMax?.Min && itemPrice <= itemPriceMinMax?.Max;
- }
-
- if (itemPriceMinMax?.Min is not null && itemPriceMinMax?.Max is null)
- {
- return itemPrice >= itemPriceMinMax?.Min;
- }
-
- if (itemPriceMinMax?.Min is null && itemPriceMinMax?.Max is not null)
- {
- return itemPrice <= itemPriceMinMax?.Max;
- }
-
- return false;
- }
- );
-
- return _cloner.Clone(filteredResult.ToDictionary(pair => pair.Key, pair => pair.Value));
+ // No loot, exit
+ return result;
}
- return _cloner.Clone(result);
+ if (itemPriceMinMax is null)
+ {
+ // No filtering requested, exit
+ return _cloner.Clone(result);
+ }
+
+ // Filter the loot pool prior to returning
+ var filteredResult = result.Where(i =>
+ {
+ var itemPrice = _itemHelper.GetItemPrice(i.Key);
+ if (itemPriceMinMax?.Min is not null && itemPriceMinMax?.Max is not null)
+ {
+ return itemPrice >= itemPriceMinMax?.Min && itemPrice <= itemPriceMinMax?.Max;
+ }
+
+ if (itemPriceMinMax?.Min is not null && itemPriceMinMax?.Max is null)
+ {
+ return itemPrice >= itemPriceMinMax?.Min;
+ }
+
+ if (itemPriceMinMax?.Min is null && itemPriceMinMax?.Max is not null)
+ {
+ return itemPrice <= itemPriceMinMax?.Max;
+ }
+
+ return false;
+ }
+ );
+
+ return _cloner.Clone(filteredResult.ToDictionary(pair => pair.Key, pair => pair.Value));
+
}
///