From 6f3ce60cec7333d4778c43b468748ab2fd866a36 Mon Sep 17 00:00:00 2001 From: Chomp Date: Mon, 14 Jul 2025 20:02:46 +0100 Subject: [PATCH] Simplified calls to `.Remove()` --- .../SPTarkov.Server.Core/Controllers/DialogueController.cs | 6 +----- .../SPTarkov.Server.Core/Controllers/InventoryController.cs | 5 +---- .../Commando/SptCommands/GiveCommand/GiveSptCommand.cs | 5 +---- Libraries/SPTarkov.Server.Core/Servers/SaveServer.cs | 6 +----- 4 files changed, 4 insertions(+), 18 deletions(-) diff --git a/Libraries/SPTarkov.Server.Core/Controllers/DialogueController.cs b/Libraries/SPTarkov.Server.Core/Controllers/DialogueController.cs index b6de0bd7..e70f3830 100644 --- a/Libraries/SPTarkov.Server.Core/Controllers/DialogueController.cs +++ b/Libraries/SPTarkov.Server.Core/Controllers/DialogueController.cs @@ -434,7 +434,7 @@ public class DialogueController( public virtual void RemoveDialogue(string? dialogueId, MongoId sessionId) { var profile = saveServer.GetProfile(sessionId); - if (!profile.DialogueRecords.ContainsKey(dialogueId)) + if (!profile.DialogueRecords.Remove(dialogueId)) { logger.Error( serverLocalisationService.GetText( @@ -442,11 +442,7 @@ public class DialogueController( new { sessionId, dialogueId } ) ); - - return; } - - profile.DialogueRecords.Remove(dialogueId); } /// diff --git a/Libraries/SPTarkov.Server.Core/Controllers/InventoryController.cs b/Libraries/SPTarkov.Server.Core/Controllers/InventoryController.cs index 8d22f7e6..69714973 100644 --- a/Libraries/SPTarkov.Server.Core/Controllers/InventoryController.cs +++ b/Libraries/SPTarkov.Server.Core/Controllers/InventoryController.cs @@ -722,10 +722,7 @@ public class InventoryController( ) { // Remove link - if (pmcData.Inventory.FastPanel.ContainsKey(bindRequest.Index)) - { - pmcData.Inventory.FastPanel.Remove(bindRequest.Index); - } + pmcData.Inventory.FastPanel.Remove(bindRequest.Index); // Create link between fast panel slot and requested item pmcData.Inventory.FastPanel[bindRequest.Index] = bindRequest.Item; 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 802f70ce..f6b8cbf2 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 @@ -113,10 +113,7 @@ public class GiveSptCommand( else { // A new give request was entered, we need to ignore the old saved command - if (_savedCommand.ContainsKey(sessionId)) - { - _savedCommand.Remove(sessionId); - } + _savedCommand.Remove(sessionId); isItemName = (!string.IsNullOrEmpty(result.Groups[5].Value)); item = diff --git a/Libraries/SPTarkov.Server.Core/Servers/SaveServer.cs b/Libraries/SPTarkov.Server.Core/Servers/SaveServer.cs index 7a51dfa1..caa429f7 100644 --- a/Libraries/SPTarkov.Server.Core/Servers/SaveServer.cs +++ b/Libraries/SPTarkov.Server.Core/Servers/SaveServer.cs @@ -1,6 +1,5 @@ using System.Collections.Concurrent; using System.Diagnostics; -using System.Text.Json; using System.Text.Json.Nodes; using SPTarkov.DI.Annotations; using SPTarkov.Server.Core.DI; @@ -52,10 +51,7 @@ public class SaveServer( /// ID of Callback to remove public void RemoveBeforeSaveCallback(string id) { - if (onBeforeSaveCallbacks.ContainsKey(id)) - { - onBeforeSaveCallbacks.Remove(id); - } + onBeforeSaveCallbacks.Remove(id); } ///