OBT/1.0.9

Fixed an issue causing gap.update crashes the game(engine issue)
Fixed an potential issue that on MacOS we cannot get core count and cause MaxDegreeOfParallelism will be set to 0. Now if we cant get that number we simply use a fixed 16 instead
This commit is contained in:
NotAlwaysTrue
2025-12-29 16:33:37 +08:00
committed by GitHub
4 changed files with 18 additions and 24 deletions
+4 -7
View File
@@ -23,16 +23,13 @@ on:
env: env:
CI_DIR: 2049ef39-42a2-46d2-b513-ee6d2e3a7b15 CI_DIR: 2049ef39-42a2-46d2-b513-ee6d2e3a7b15
RELEASES: | RELEASES: |
windows:client:Windows/Client
windows:server:Windows/Server windows:server:Windows/Server
linux:client:Linux/Client
linux:server:Linux/Server linux:server:Linux/Server
mac:client:Mac/Client/Barotrauma.app/Contents/MacOS
mac:server:Mac/Server mac:server:Mac/Server
ARCHIVE_BASE_NAME: luacsforbarotraumaEP ARCHIVE_BASE_NAME: luacsforbarotrauma
# windows:client:Windows/Client
# linux:client:Linux/Client
# mac:client:Mac/Client/Barotrauma.app/Contents/MacOS
# we do not currently provide a CL
# XXX: these file names are subject to shell expansion. # XXX: these file names are subject to shell expansion.
# Be careful when using special characters. # Be careful when using special characters.
ARCHIVE_FILES_SERVER: | ARCHIVE_FILES_SERVER: |
@@ -646,13 +646,17 @@ namespace Barotrauma
var sw = new System.Diagnostics.Stopwatch(); var sw = new System.Diagnostics.Stopwatch();
sw.Start(); sw.Start();
#endif #endif
// Buffer lists to avoid repeated allocations // Buffer lists to avoid repeated allocations
var hullList = Hull.HullList.ToList(); var hullList = Hull.HullList.ToList();
var structureList = Structure.WallList.ToList(); var structureList = Structure.WallList.ToList();
var gapList = Gap.GapList.ToList(); var gapList = Gap.GapList.ToList();
var itemList = Item.ItemList.ToList(); var itemList = Item.ItemList.ToList();
Parallel.ForEach(gapList, parallelOptions, gap =>
{
gap.ResetWaterFlowThisFrame();
});
// First phase: parallel updates that have no order dependencies // First phase: parallel updates that have no order dependencies
Parallel.Invoke(parallelOptions, Parallel.Invoke(parallelOptions,
() => () =>
@@ -674,10 +678,13 @@ namespace Barotrauma
// Gap reset (must be done before update) // Gap reset (must be done before update)
() => () =>
{ {
Parallel.ForEach(gapList, parallelOptions, gap => // 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.ResetWaterFlowThisFrame(); gap.Update(deltaTime, cam);
}); }
}, },
// Powered components update // Powered components update
() => () =>
@@ -689,16 +696,6 @@ namespace Barotrauma
#if CLIENT #if CLIENT
// Hull Cheats need to be executed after Hull update // Hull Cheats need to be executed after Hull update
Hull.UpdateCheats(deltaTime, cam); Hull.UpdateCheats(deltaTime, cam);
#endif
// Gap update (has order dependencies, keep random order but execute sequentially)
var shuffledGaps = gapList.OrderBy(g => Rand.Int(int.MaxValue)).ToList();
Parallel.ForEach(gapList, parallelOptions, gap =>
{
gap.Update(deltaTime, cam);
});
#if CLIENT
sw.Stop(); sw.Stop();
GameMain.PerformanceCounter.AddElapsedTicks("Update:MapEntity:Misc", sw.ElapsedTicks); GameMain.PerformanceCounter.AddElapsedTicks("Update:MapEntity:Misc", sw.ElapsedTicks);
sw.Restart(); sw.Restart();
@@ -25,7 +25,7 @@ namespace Barotrauma
private static readonly ParallelOptions parallelOptions = new ParallelOptions private static readonly ParallelOptions parallelOptions = new ParallelOptions
{ {
MaxDegreeOfParallelism = Environment.ProcessorCount * 2, MaxDegreeOfParallelism = Environment.ProcessorCount > 0 ? Environment.ProcessorCount * 2 : 16,
}; };
#if CLIENT #if CLIENT
+1 -1
View File
@@ -1,4 +1,4 @@
# LuaCsForBarotrauma Enhanced Performance Project # LuaCsForBarotrauma Enhanced Performence Project
> ⚠ **Warning** This release is only available for server-side use and is not recommended to run on the client. Make sure that compatibility is adequately tested before deployment. > ⚠ **Warning** This release is only available for server-side use and is not recommended to run on the client. Make sure that compatibility is adequately tested before deployment.