From 6619def3654789d3955eaf29e19b054ac6f9a72f Mon Sep 17 00:00:00 2001 From: Evil Factory <36804725+evilfactory@users.noreply.github.com> Date: Wed, 28 Jan 2026 21:41:42 -0300 Subject: [PATCH] The concurrent toolbox dictionary situation is crazy --- Barotrauma/BarotraumaShared/SharedSource/Utils/ToolBox.cs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/Barotrauma/BarotraumaShared/SharedSource/Utils/ToolBox.cs b/Barotrauma/BarotraumaShared/SharedSource/Utils/ToolBox.cs index a96376047..f8c13c177 100644 --- a/Barotrauma/BarotraumaShared/SharedSource/Utils/ToolBox.cs +++ b/Barotrauma/BarotraumaShared/SharedSource/Utils/ToolBox.cs @@ -11,6 +11,7 @@ using System.Net; using System.Reflection; using System.Security.Cryptography; using System.Text; +using System.Collections.Concurrent; namespace Barotrauma { @@ -75,7 +76,7 @@ namespace Barotrauma return !corrected; } - private static readonly Dictionary cachedFileNames = new Dictionary(); + private static readonly ConcurrentDictionary cachedFileNames = new ConcurrentDictionary(); public static string CorrectFilenameCase(string filename, out bool corrected, string directory = "") { @@ -153,7 +154,7 @@ namespace Barotrauma if (i < subDirs.Length - 1) { filename += "/"; } } - cachedFileNames.Add(originalFilename, filename); + cachedFileNames.TryAdd(originalFilename, filename); return filename; }