From 56957147aa4d93d28325850db661f2c632fc90ce Mon Sep 17 00:00:00 2001 From: Chomp Date: Fri, 14 Mar 2025 19:15:55 +0000 Subject: [PATCH] Fixed error in `CheckForOrphanedModdedItems` --- .../Services/ProfileFixerService.cs | 29 ++++++++----------- 1 file changed, 12 insertions(+), 17 deletions(-) diff --git a/Libraries/SPTarkov.Server.Core/Services/ProfileFixerService.cs b/Libraries/SPTarkov.Server.Core/Services/ProfileFixerService.cs index 3a055a84..29ec207e 100644 --- a/Libraries/SPTarkov.Server.Core/Services/ProfileFixerService.cs +++ b/Libraries/SPTarkov.Server.Core/Services/ProfileFixerService.cs @@ -649,17 +649,14 @@ public class ProfileFixerService( } } - var clothing = _databaseService.GetTemplates().Customization; - foreach (var suit in fullProfile.Suits) + var clothingDb = _databaseService.GetTemplates().Customization; + foreach (var suitId in fullProfile.Suits.Where(suitId => !clothingDb.ContainsKey(suitId))) { - if (suit is null) + _logger.Error(_localisationService.GetText("fixer-clothing_item_found", suitId)); + if (_coreConfig.Fixes.RemoveModItemsFromProfile) { - _logger.Error(_localisationService.GetText("fixer-clothing_item_found", suit)); - if (_coreConfig.Fixes.RemoveModItemsFromProfile) - { - fullProfile.Suits.Remove(suit); - _logger.Warning($"Non-default suit purchase: {suit} removed from profile"); - } + fullProfile.Suits.Remove(suitId); + _logger.Warning($"Non-default suit purchase: {suitId} removed from profile"); } } @@ -706,16 +703,14 @@ public class ProfileFixerService( } } - foreach (var TraderPurchase in fullProfile.TraderPurchases) + foreach (var TraderPurchaseKvP in fullProfile.TraderPurchases + .Where(TraderPurchase => !_traderHelper.TraderEnumHasValue(TraderPurchase.Key))) { - if (!_traderHelper.TraderEnumHasValue(TraderPurchase.Key)) + _logger.Error(_localisationService.GetText("fixer-trader_found", TraderPurchaseKvP.Key)); + if (_coreConfig.Fixes.RemoveModItemsFromProfile) { - _logger.Error(_localisationService.GetText("fixer-trader_found", TraderPurchase.Key)); - if (_coreConfig.Fixes.RemoveModItemsFromProfile) - { - _logger.Warning($"Non-default trader: {TraderPurchase.Key} purchase removed from traderPurchases list in profile"); - fullProfile.TraderPurchases.Remove(TraderPurchase.Key); - } + _logger.Warning($"Non-default trader: {TraderPurchaseKvP.Key} purchase removed from traderPurchases list in profile"); + fullProfile.TraderPurchases.Remove(TraderPurchaseKvP.Key); } } }