From 3d96e4adb6a3f6d3f024c8bba808442e795f1b11 Mon Sep 17 00:00:00 2001 From: NotAlwaysTrue <2136846186@qq.com> Date: Sun, 28 Dec 2025 13:02:31 +0800 Subject: [PATCH] Fixed #22 --- Barotrauma/BarotraumaShared/SharedSource/Map/Gap.cs | 7 ++----- Barotrauma/BarotraumaShared/SharedSource/Map/MapEntity.cs | 6 +++--- 2 files changed, 5 insertions(+), 8 deletions(-) diff --git a/Barotrauma/BarotraumaShared/SharedSource/Map/Gap.cs b/Barotrauma/BarotraumaShared/SharedSource/Map/Gap.cs index 94b8bd03e..6f7c132da 100644 --- a/Barotrauma/BarotraumaShared/SharedSource/Map/Gap.cs +++ b/Barotrauma/BarotraumaShared/SharedSource/Map/Gap.cs @@ -745,7 +745,6 @@ namespace Barotrauma waterFlowThisFrame = 0.0f; } - private static readonly HashSet checkedHulls = new HashSet(); /// /// Simulates water flow from the source to all the hulls it's connected to across the sub, as if the water was coming directly from outside. @@ -753,7 +752,7 @@ namespace Barotrauma /// void SimulateWaterFlowFromOutsideToConnectedHulls(Hull hull, float maxFlow, float deltaTime) { - checkedHulls.Clear(); + List checkedHulls = new List(); checkedHulls.Add(hull); foreach (var connectedGap in hull.ConnectedGaps) { @@ -764,7 +763,7 @@ namespace Barotrauma } } - static void SimulateWaterFlowFromOutsideToConnectedHullsRecursive(Hull targetHull, Gap gap, HashSet checkedHulls, Hull originHull, float maxFlow, float deltaTime) + static void SimulateWaterFlowFromOutsideToConnectedHullsRecursive(Hull targetHull, Gap gap, List checkedHulls, Hull originHull, float maxFlow, float deltaTime) { const float decay = 0.95f; @@ -995,8 +994,6 @@ namespace Barotrauma base.Remove(); GapList.Remove(this); - checkedHulls.Clear(); - foreach (Hull hull in Hull.HullList) { hull.ConnectedGaps.Remove(this); diff --git a/Barotrauma/BarotraumaShared/SharedSource/Map/MapEntity.cs b/Barotrauma/BarotraumaShared/SharedSource/Map/MapEntity.cs index 2634f9560..7ef1b529e 100644 --- a/Barotrauma/BarotraumaShared/SharedSource/Map/MapEntity.cs +++ b/Barotrauma/BarotraumaShared/SharedSource/Map/MapEntity.cs @@ -655,13 +655,13 @@ namespace Barotrauma // First phase: parallel updates that have no order dependencies Parallel.Invoke(parallelOptions, - // Hull parallel update () => { - Parallel.ForEach(hullList, parallelOptions, hull => + // basically nothing here is thread-safe so + foreach(var hull in hullList) { hull.Update(deltaTime, cam); - }); + } }, // Structure parallel update () =>