Skip to content

Commit 82d26b5

Browse files
OBT/1.0.11
Fixed a bug that caused the server to stop responding Fixed an issue in gap.Update that may cause the server to crash
1 parent 4c151a4 commit 82d26b5

4 files changed

Lines changed: 22 additions & 7 deletions

File tree

Barotrauma/BarotraumaShared/SharedSource/Map/Gap.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -812,7 +812,7 @@ public bool RefreshOutsideCollider()
812812
if (outsideCollisionBlocker == null) { return false; }
813813
if (IsRoomToRoom || Submarine == null || open <= 0.0f || linkedTo.Count == 0 || linkedTo[0] is not Hull)
814814
{
815-
outsideCollisionBlocker.Enabled = false;
815+
outsideCollisionBlocker.AddToDisableQueue();
816816
return false;
817817
}
818818

Barotrauma/BarotraumaShared/SharedSource/Map/MapEntity.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -686,6 +686,7 @@ public static void UpdateAll(float deltaTime, Camera cam, ParallelOptions parall
686686
gap.ResetWaterFlowThisFrame();
687687
gap.Update(deltaTime, cam);
688688
});
689+
FarseerPhysics.Dynamics.Body.QueueDisable();
689690
},
690691
// Powered components update
691692
() =>

Barotrauma/BarotraumaShared/SharedSource/Screens/GameScreen.cs

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -245,10 +245,10 @@ public override void Update(double deltaTime)
245245
Character.Controlled?.UpdateLocalCursor(cam);
246246

247247
#elif SERVER
248-
Parallel.Invoke(parallelOptions,
249-
() => { if (Level.Loaded != null) Level.Loaded.Update((float)deltaTime, Camera.Instance); },
250-
() => Character.UpdateAll((float)deltaTime, Camera.Instance)
251-
);
248+
249+
// Don't parallize these things here or the server may got stuck but why idk
250+
if (Level.Loaded != null) { Level.Loaded.Update((float)deltaTime, Camera.Instance); }
251+
Character.UpdateAll((float)deltaTime, Camera.Instance);
252252

253253
//StatusEffect.UpdateAll is not thread-safe and must be executed on the main thread
254254
StatusEffect.UpdateAll((float)deltaTime);
@@ -272,9 +272,7 @@ public override void Update(double deltaTime)
272272
#if CLIENT
273273
MapEntity.UpdateAll((float)deltaTime, cam, parallelOptions);
274274
#elif SERVER
275-
276275
MapEntity.UpdateAll((float)deltaTime, Camera.Instance, parallelOptions);
277-
278276
#endif
279277

280278
#if CLIENT

Libraries/Farseer Physics Engine 3.5/Dynamics/Body.cs

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929

3030

3131
using System;
32+
using System.Collections.Concurrent;
3233
using System.Collections.Generic;
3334
using System.Diagnostics;
3435
using System.Linq;
@@ -349,6 +350,21 @@ public bool Enabled
349350
}
350351
}
351352

353+
private static ConcurrentQueue<Body> DisableQueue = new ConcurrentQueue<Body>();
354+
355+
public static void QueueDisable()
356+
{
357+
while (DisableQueue.TryDequeue(out var pendingbody))
358+
{
359+
pendingbody.Enabled = false;
360+
}
361+
}
362+
363+
public void AddToDisableQueue()
364+
{
365+
DisableQueue.Enqueue(this);
366+
}
367+
352368
/// <summary>
353369
/// Create all proxies.
354370
/// </summary>

0 commit comments

Comments
 (0)