diff --git a/OpenRA.Game/GameRules/Settings.cs b/OpenRA.Game/GameRules/Settings.cs index ad753bc696..6ef91343f2 100755 --- a/OpenRA.Game/GameRules/Settings.cs +++ b/OpenRA.Game/GameRules/Settings.cs @@ -34,6 +34,7 @@ namespace OpenRA.GameRules public bool BotDebug = false; public bool PerfGraph = false; public float LongTickThreshold = 0.001f; + public bool SanityCheckUnsyncedCode = false; } public class GraphicSettings diff --git a/OpenRA.Game/Sync.cs b/OpenRA.Game/Sync.cs index 9e502cfcfe..86c83dc59a 100755 --- a/OpenRA.Game/Sync.cs +++ b/OpenRA.Game/Sync.cs @@ -140,9 +140,11 @@ namespace OpenRA public static T CheckSyncUnchanged( World world, Func fn ) { if( world == null ) return fn(); - int sync = world.SyncHash(); + var shouldCheckSync = Game.Settings.Debug.SanityCheckUnsyncedCode; + int sync = shouldCheckSync ? world.SyncHash() : 0; bool prevInUnsyncedCode = inUnsyncedCode; inUnsyncedCode = true; + try { return fn(); @@ -150,7 +152,7 @@ namespace OpenRA finally { inUnsyncedCode = prevInUnsyncedCode; - if( sync != world.SyncHash() ) + if( shouldCheckSync && sync != world.SyncHash() ) throw new InvalidOperationException( "CheckSyncUnchanged: sync-changing code may not run here" ); } } diff --git a/OpenRA.Mods.RA/Widgets/Delegates/SettingsMenuDelegate.cs b/OpenRA.Mods.RA/Widgets/Delegates/SettingsMenuDelegate.cs index c4b6a130e3..69de7efb6b 100755 --- a/OpenRA.Mods.RA/Widgets/Delegates/SettingsMenuDelegate.cs +++ b/OpenRA.Mods.RA/Widgets/Delegates/SettingsMenuDelegate.cs @@ -123,6 +123,7 @@ namespace OpenRA.Mods.RA.Widgets.Delegates var debug = bg.GetWidget("DEBUG_PANE"); debug.GetWidget("PERFDEBUG_CHECKBOX").Bind(Game.Settings.Debug, "PerfGraph"); debug.GetWidget("GAMETIME_CHECKBOX").Bind(Game.Settings.Game, "MatchTimer"); + debug.GetWidget("CHECKUNSYNCED_CHECKBOX").Bind(Game.Settings.Debug, "SanityCheckUnsyncedCode"); bg.GetWidget("BUTTON_CLOSE").OnMouseUp = mi => { Game.Settings.Save(); diff --git a/mods/cnc/chrome/settings.yaml b/mods/cnc/chrome/settings.yaml index 6cb97571c8..c257261a79 100644 --- a/mods/cnc/chrome/settings.yaml +++ b/mods/cnc/chrome/settings.yaml @@ -217,3 +217,10 @@ Background@SETTINGS_MENU: Width:300 Height:20 Text:Show Game Time Counter + Checkbox@CHECKUNSYNCED_CHECKBOX: + Id:CHECKUNSYNCED_CHECKBOX + X:0 + Y:60 + Width:300 + Height:20 + Text:Check Sync around Unsynced Code diff --git a/mods/ra/chrome/settings.yaml b/mods/ra/chrome/settings.yaml index 6cb97571c8..c257261a79 100644 --- a/mods/ra/chrome/settings.yaml +++ b/mods/ra/chrome/settings.yaml @@ -217,3 +217,10 @@ Background@SETTINGS_MENU: Width:300 Height:20 Text:Show Game Time Counter + Checkbox@CHECKUNSYNCED_CHECKBOX: + Id:CHECKUNSYNCED_CHECKBOX + X:0 + Y:60 + Width:300 + Height:20 + Text:Check Sync around Unsynced Code