OBT/1.0.10

Reverted a fixed bug that caused a rare crash but the fix itself will do impact on server performance
This commit is contained in:
NotAlwaysTrue
2025-12-29 22:52:29 +08:00
committed by GitHub

View File

@@ -646,17 +646,13 @@ namespace Barotrauma
var sw = new System.Diagnostics.Stopwatch();
sw.Start();
#endif
// Buffer lists to avoid repeated allocations
var hullList = Hull.HullList.ToList();
var structureList = Structure.WallList.ToList();
var gapList = Gap.GapList.ToList();
var itemList = Item.ItemList.ToList();
Parallel.ForEach(gapList, parallelOptions, gap =>
{
gap.ResetWaterFlowThisFrame();
});
// First phase: parallel updates that have no order dependencies
Parallel.Invoke(parallelOptions,
() =>
@@ -675,16 +671,21 @@ namespace Barotrauma
structure.Update(deltaTime, cam);
});
},
// Gap reset (must be done before update)
() =>
{
// Gap update (has order dependencies, keep random order but execute sequentially)
var shuffledGaps = gapList.OrderBy(g => Rand.Int(int.MaxValue)).ToList();
foreach (var gap in shuffledGaps)
{
gap.Update(deltaTime, cam);
}
//update gaps in random order, because otherwise in rooms with multiple gaps
//the water/air will always tend to flow through the first gap in the list,
//which may lead to weird behavior like water draining down only through
//one gap in a room even if there are several
// moved waterflow reset here to see if we can reduce at least some time
{
// if crashed, go ask the god damn physics engine :(
var shuffledGaps = gapList.OrderBy(g => Rand.Int(int.MaxValue)).ToList();
Parallel.ForEach(gapList, parallelOptions, gap =>
{
gap.ResetWaterFlowThisFrame();
gap.Update(deltaTime, cam);
});
},
// Powered components update
() =>
@@ -696,6 +697,9 @@ namespace Barotrauma
#if CLIENT
// Hull Cheats need to be executed after Hull update
Hull.UpdateCheats(deltaTime, cam);
#endif
#if CLIENT
sw.Stop();
GameMain.PerformanceCounter.AddElapsedTicks("Update:MapEntity:Misc", sw.ElapsedTicks);
sw.Restart();