From 1dc0a603c75132776f669789e89596b15245ea26 Mon Sep 17 00:00:00 2001 From: abcdefg30 Date: Fri, 3 Sep 2021 21:58:25 +0200 Subject: [PATCH] Directly run unsynced functions if we don't check sync hashes --- OpenRA.Game/Sync.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/OpenRA.Game/Sync.cs b/OpenRA.Game/Sync.cs index 542de78c6c..ad16043773 100644 --- a/OpenRA.Game/Sync.cs +++ b/OpenRA.Game/Sync.cs @@ -181,10 +181,10 @@ namespace OpenRA public static T RunUnsynced(bool checkSyncHash, World world, Func fn) { // PERF: Detect sync changes in top level entry point only. Do not recalculate sync hash during reentry. - if (inUnsyncedCode || world == null) + if (!checkSyncHash || inUnsyncedCode || world == null) return fn(); - var sync = checkSyncHash ? world.SyncHash() : 0; + var sync = world.SyncHash(); inUnsyncedCode = true; try @@ -194,7 +194,7 @@ namespace OpenRA finally { inUnsyncedCode = false; - if (checkSyncHash && sync != world.SyncHash()) + if (sync != world.SyncHash()) throw new InvalidOperationException("RunUnsynced: sync-changing code may not run here"); } }