From b91d08b538a04e6d962d598f8b414c2194f56861 Mon Sep 17 00:00:00 2001 From: Chomp Date: Sun, 13 Apr 2025 09:34:15 +0100 Subject: [PATCH] FIxed `AddContainerImprovementToProfile` saving incorrect value into `HideoutAreaStashes` dictionary --- .../Controllers/HideoutController.cs | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/Libraries/SPTarkov.Server.Core/Controllers/HideoutController.cs b/Libraries/SPTarkov.Server.Core/Controllers/HideoutController.cs index 491b768e..a93a116a 100644 --- a/Libraries/SPTarkov.Server.Core/Controllers/HideoutController.cs +++ b/Libraries/SPTarkov.Server.Core/Controllers/HideoutController.cs @@ -256,15 +256,20 @@ public class HideoutController( /// Session/Player id /// Players PMC profile /// - /// - /// + /// Area of hideout player is upgrading + /// Stage player is upgrading to protected void AddContainerImprovementToProfile(ItemEventRouterResponse output, string sessionID, PmcData pmcData, BotHideoutArea profileParentHideoutArea, HideoutArea dbHideoutArea, Stage hideoutStage) { // Add key/value to `hideoutAreaStashes` dictionary - used to link hideout area to inventory stash by its id - if (!pmcData.Inventory.HideoutAreaStashes.ContainsKey(dbHideoutArea.Type.ToString())) + // Key is the enums value stored as a string, e.g. "27" for cultist circle + var keyForHideoutAreaStash = ((int) dbHideoutArea.Type).ToString(); + if (!pmcData.Inventory.HideoutAreaStashes.ContainsKey(keyForHideoutAreaStash)) { - pmcData.Inventory.HideoutAreaStashes[dbHideoutArea.Type.ToString()] = dbHideoutArea.Id; + if (!pmcData.Inventory.HideoutAreaStashes.TryAdd(keyForHideoutAreaStash, dbHideoutArea.Id)) + { + _logger.Error($"Unable to add key: {dbHideoutArea.Type} to HideoutAreaStashes"); + } } // Add/upgrade stash item in player inventory @@ -277,7 +282,7 @@ public class HideoutController( AddMissingPresetStandItemsToProfile(sessionID, hideoutStage, pmcData, dbHideoutArea, output); } - // Dont inform client when upgraded area is hall of fame or equipment stand, BSG doesn't inform client this specifc upgrade has occurred + // Don't inform client when upgraded area is hall of fame or equipment stand, BSG doesn't inform client this specific upgrade has occurred // will break client if sent HashSet check = [HideoutAreas.PLACE_OF_FAME]; if (!check.Contains(dbHideoutArea.Type ?? HideoutAreas.NOTSET))