diff --git a/Barotrauma/BarotraumaShared/SharedSource/Map/MapEntity.cs b/Barotrauma/BarotraumaShared/SharedSource/Map/MapEntity.cs index 97b3a8697d..cc04729fc0 100644 --- a/Barotrauma/BarotraumaShared/SharedSource/Map/MapEntity.cs +++ b/Barotrauma/BarotraumaShared/SharedSource/Map/MapEntity.cs @@ -650,8 +650,12 @@ public static void UpdateAll(float deltaTime, Camera cam, ParallelOptions parall // Buffer lists to avoid repeated allocations var hullList = Hull.HullList.ToList(); var structureList = Structure.WallList.ToList(); - // First, WHY THIS LINQ GOT A NULL ERROR? Second, WHY?? - List shuffledGaps = Gap.GapList?.OrderBy(g => Rand.Int(int.MaxValue)).ToList() ?? Gap.GapList.ToList(); + + List gapList = Gap.GapList.ToList(); + List shuffledGaps = new List(gapList?.OrderBy(g => Rand.Int(int.MaxValue))); + // In case if it failed, but why it would fail? + shuffledGaps = shuffledGaps ?? gapList; + var itemList = Item.ItemList.ToList(); // First phase: parallel updates that have no order dependencies @@ -680,7 +684,7 @@ public static void UpdateAll(float deltaTime, Camera cam, ParallelOptions parall // moved waterflow reset here to see if we can reduce at least some time { - if (shuffledGaps == null) { shuffledGaps = Gap.GapList; } + // PLEASE WORK Parallel.ForEach(shuffledGaps, parallelOptions, gap => { gap.ResetWaterFlowThisFrame();