From ecdefef16c302124b9b0f803315a86f9ba6a56c0 Mon Sep 17 00:00:00 2001 From: Chomp Date: Sat, 19 Jul 2025 14:29:51 +0100 Subject: [PATCH] Removed unnecessary clone of db when checking for chat item + prevented some boxing issues --- .../SptCommands/GiveCommand/GiveSptCommand.cs | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/Libraries/SPTarkov.Server.Core/Helpers/Dialogue/Commando/SptCommands/GiveCommand/GiveSptCommand.cs b/Libraries/SPTarkov.Server.Core/Helpers/Dialogue/Commando/SptCommands/GiveCommand/GiveSptCommand.cs index 72476843..4a2618eb 100644 --- a/Libraries/SPTarkov.Server.Core/Helpers/Dialogue/Commando/SptCommands/GiveCommand/GiveSptCommand.cs +++ b/Libraries/SPTarkov.Server.Core/Helpers/Dialogue/Commando/SptCommands/GiveCommand/GiveSptCommand.cs @@ -18,6 +18,7 @@ namespace SPTarkov.Server.Core.Helpers.Dialogue.Commando.SptCommands.GiveCommand public class GiveSptCommand( ISptLogger _logger, ItemHelper _itemHelper, + DatabaseService databaseService, PresetHelper _presetHelper, ItemFilterService _itemFilterService, MailSendService _mailSendService, @@ -31,7 +32,7 @@ public class GiveSptCommand( ); // Exception for flares - protected static readonly FrozenSet _excludedPresetItems = + protected static readonly FrozenSet _excludedPresetItems = [ ItemTpl.FLARE_RSP30_REACTIVE_SIGNAL_CARTRIDGE_RED, ItemTpl.FLARE_RSP30_REACTIVE_SIGNAL_CARTRIDGE_GREEN, @@ -151,9 +152,9 @@ public class GiveSptCommand( } localizedGlobal = GetGlobalsLocale(locale); - var allAllowedItemNames = _itemHelper - .GetItemsClone() - .Where(IsItemAllowed) + var allAllowedItemNames = databaseService + .GetItems() + .Values.Where(IsItemAllowed) .Select(i => localizedGlobal .GetValueOrDefault($"{i.Id} Name", i.Properties.Name) @@ -206,9 +207,9 @@ public class GiveSptCommand( // If item is an item name, we need to search using that item name and the locale which one we want otherwise // item is just the tplId. MongoId tplId = isItemName - ? _itemHelper - .GetItemsClone() - .Where(IsItemAllowed) + ? databaseService + .GetItems() + .Values.Where(IsItemAllowed) .FirstOrDefault(i => (localizedGlobal[$"{i?.Id} Name"]?.ToLowerInvariant() ?? i.Properties.Name) == item