Fixed multiple LINQ using shared resources and cause crashes

Added an null check in AIObjectiveManager.cs to avoid accessing removed resources
Use shuffledGaps instead of gapList to ensure update order requirement(already in master)
Updated parallelism count
This commit is contained in:
NotAlwaysTrue
2026-01-09 18:09:49 +08:00
parent caec44c57d
commit e7e444e9b2
5 changed files with 24 additions and 36 deletions
@@ -816,7 +816,7 @@ namespace Barotrauma
// 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 =>
Parallel.ForEach(shuffledGaps, parallelOptions, gap =>
{
PhysicsBodyQueue.IsInParallelContext = true;
try