Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 7 additions & 3 deletions Barotrauma/BarotraumaShared/SharedSource/Map/MapEntity.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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<Gap> shuffledGaps = Gap.GapList?.OrderBy(g => Rand.Int(int.MaxValue)).ToList() ?? Gap.GapList.ToList();

List<Gap> gapList = Gap.GapList.ToList();
List<Gap> shuffledGaps = new List<Gap>(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
Expand Down Expand Up @@ -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();
Expand Down