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
This commit is contained in:
NotAlwaysTrue
2025-12-30 17:41:50 +08:00
committed by GitHub
parent 4c151a4cf1
commit 82d26b5bb8
4 changed files with 22 additions and 7 deletions
@@ -812,7 +812,7 @@ namespace Barotrauma
if (outsideCollisionBlocker == null) { return false; } if (outsideCollisionBlocker == null) { return false; }
if (IsRoomToRoom || Submarine == null || open <= 0.0f || linkedTo.Count == 0 || linkedTo[0] is not Hull) if (IsRoomToRoom || Submarine == null || open <= 0.0f || linkedTo.Count == 0 || linkedTo[0] is not Hull)
{ {
outsideCollisionBlocker.Enabled = false; outsideCollisionBlocker.AddToDisableQueue();
return false; return false;
} }
@@ -686,6 +686,7 @@ namespace Barotrauma
gap.ResetWaterFlowThisFrame(); gap.ResetWaterFlowThisFrame();
gap.Update(deltaTime, cam); gap.Update(deltaTime, cam);
}); });
FarseerPhysics.Dynamics.Body.QueueDisable();
}, },
// Powered components update // Powered components update
() => () =>
@@ -245,10 +245,10 @@ namespace Barotrauma
Character.Controlled?.UpdateLocalCursor(cam); Character.Controlled?.UpdateLocalCursor(cam);
#elif SERVER #elif SERVER
Parallel.Invoke(parallelOptions,
() => { if (Level.Loaded != null) Level.Loaded.Update((float)deltaTime, Camera.Instance); }, // Don't parallize these things here or the server may got stuck but why idk
() => Character.UpdateAll((float)deltaTime, Camera.Instance) if (Level.Loaded != null) { Level.Loaded.Update((float)deltaTime, Camera.Instance); }
); Character.UpdateAll((float)deltaTime, Camera.Instance);
//StatusEffect.UpdateAll is not thread-safe and must be executed on the main thread //StatusEffect.UpdateAll is not thread-safe and must be executed on the main thread
StatusEffect.UpdateAll((float)deltaTime); StatusEffect.UpdateAll((float)deltaTime);
@@ -272,9 +272,7 @@ namespace Barotrauma
#if CLIENT #if CLIENT
MapEntity.UpdateAll((float)deltaTime, cam, parallelOptions); MapEntity.UpdateAll((float)deltaTime, cam, parallelOptions);
#elif SERVER #elif SERVER
MapEntity.UpdateAll((float)deltaTime, Camera.Instance, parallelOptions); MapEntity.UpdateAll((float)deltaTime, Camera.Instance, parallelOptions);
#endif #endif
#if CLIENT #if CLIENT
@@ -29,6 +29,7 @@
using System; using System;
using System.Collections.Concurrent;
using System.Collections.Generic; using System.Collections.Generic;
using System.Diagnostics; using System.Diagnostics;
using System.Linq; using System.Linq;
@@ -349,6 +350,21 @@ namespace FarseerPhysics.Dynamics
} }
} }
private static ConcurrentQueue<Body> DisableQueue = new ConcurrentQueue<Body>();
public static void QueueDisable()
{
while (DisableQueue.TryDequeue(out var pendingbody))
{
pendingbody.Enabled = false;
}
}
public void AddToDisableQueue()
{
DisableQueue.Enqueue(this);
}
/// <summary> /// <summary>
/// Create all proxies. /// Create all proxies.
/// </summary> /// </summary>