From 5b823d868452c0b6e5a4b6603081d1db80f0f142 Mon Sep 17 00:00:00 2001 From: eero Date: Mon, 22 Dec 2025 18:07:17 +0800 Subject: [PATCH] Clarify thread safety in update methods Updated comments in GameScreen.cs to indicate that StatusEffect.UpdateAll and Character.UpdateAnimAll are not thread-safe and must be executed on the main thread. Also removed a non-English comment from MapEntity.cs for consistency. --- Barotrauma/BarotraumaShared/SharedSource/Map/MapEntity.cs | 2 +- .../BarotraumaShared/SharedSource/Screens/GameScreen.cs | 5 +++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/Barotrauma/BarotraumaShared/SharedSource/Map/MapEntity.cs b/Barotrauma/BarotraumaShared/SharedSource/Map/MapEntity.cs index d1ed202fa..48ea30861 100644 --- a/Barotrauma/BarotraumaShared/SharedSource/Map/MapEntity.cs +++ b/Barotrauma/BarotraumaShared/SharedSource/Map/MapEntity.cs @@ -638,7 +638,7 @@ namespace Barotrauma } /// - /// Call Update() on every object in Entity.list - 完全并行版本 + /// Call Update() on every object in Entity.list /// public static void UpdateAll(float deltaTime, Camera cam , ParallelOptions parallelOptions) { diff --git a/Barotrauma/BarotraumaShared/SharedSource/Screens/GameScreen.cs b/Barotrauma/BarotraumaShared/SharedSource/Screens/GameScreen.cs index c5bdb54f8..e29da7114 100644 --- a/Barotrauma/BarotraumaShared/SharedSource/Screens/GameScreen.cs +++ b/Barotrauma/BarotraumaShared/SharedSource/Screens/GameScreen.cs @@ -276,8 +276,9 @@ namespace Barotrauma MapEntity.UpdateAll((float)deltaTime, cam, parallelOptions); #elif SERVER - // TODO: Move both UpdateAll() method to this file + MapEntity.UpdateAll((float)deltaTime, Camera.Instance, parallelOptions); + //StatusEffect.UpdateAll is not thread-safe and must be executed on the main thread StatusEffect.UpdateAll((float)deltaTime); #endif @@ -287,7 +288,7 @@ namespace Barotrauma GameMain.PerformanceCounter.AddElapsedTicks("Update:MapEntity", sw.ElapsedTicks); sw.Restart(); #endif - + //Character.UpdateAnimAll is not thread-safe and must be executed on the main thread Character.UpdateAnimAll((float)deltaTime); #if CLIENT