diff --git a/OpenRA.Game/Settings.cs b/OpenRA.Game/Settings.cs index d9c2748991..203a36209f 100644 --- a/OpenRA.Game/Settings.cs +++ b/OpenRA.Game/Settings.cs @@ -96,6 +96,7 @@ namespace OpenRA public float LongTickThresholdMs = 1; public bool SyncCheckUnsyncedCode = false; + public bool SyncCheckBotModuleCode = false; public int Samples = 25; public bool StrictActivityChecking = false; diff --git a/OpenRA.Mods.Common/AI/HackyAI.cs b/OpenRA.Mods.Common/AI/HackyAI.cs index f2dc1407f8..3df5f177ff 100644 --- a/OpenRA.Mods.Common/AI/HackyAI.cs +++ b/OpenRA.Mods.Common/AI/HackyAI.cs @@ -358,13 +358,15 @@ namespace OpenRA.Mods.Common.AI AssignRolesToIdleUnits(self); - // TODO: Add an option to include this in CheckSyncUnchanged. - // Checking sync for this is too expensive to include it by default, - // so it should be implemented as separate sub-option checkbox. using (new PerfSample("bot_tick")) - foreach (var t in tickModules) - if (t.IsTraitEnabled()) - t.BotTick(this); + { + Sync.RunUnsynced(Game.Settings.Debug.SyncCheckBotModuleCode, World, () => + { + foreach (var t in tickModules) + if (t.IsTraitEnabled()) + t.BotTick(this); + }); + } var ordersToIssueThisTick = Math.Min((orders.Count + Info.MinOrderQuotientPerTick - 1) / Info.MinOrderQuotientPerTick, orders.Count); for (var i = 0; i < ordersToIssueThisTick; i++) @@ -543,11 +545,14 @@ namespace OpenRA.Mods.Common.AI if (mcv == null) return; - foreach (var n in positionsUpdatedModules) + Sync.RunUnsynced(Game.Settings.Debug.SyncCheckBotModuleCode, World, () => { - n.UpdatedBaseCenter(mcv.Location); - n.UpdatedDefenseCenter(mcv.Location); - } + foreach (var n in positionsUpdatedModules) + { + n.UpdatedBaseCenter(mcv.Location); + n.UpdatedDefenseCenter(mcv.Location); + } + }); } void IBotPositionsUpdated.UpdatedBaseCenter(CPos newLocation) @@ -650,9 +655,14 @@ namespace OpenRA.Mods.Common.AI // Checking sync for this is too expensive to include it by default, // so it should be implemented as separate sub-option checkbox. using (new PerfSample("bot_attack_response")) - foreach (var t in attackResponseModules) - if (t.IsTraitEnabled()) - t.RespondToAttack(this, self, e); + { + Sync.RunUnsynced(Game.Settings.Debug.SyncCheckBotModuleCode, World, () => + { + foreach (var t in attackResponseModules) + if (t.IsTraitEnabled()) + t.RespondToAttack(this, self, e); + }); + } if (e.Attacker == null || e.Attacker.Disposed) return; diff --git a/OpenRA.Mods.Common/Widgets/Logic/SettingsLogic.cs b/OpenRA.Mods.Common/Widgets/Logic/SettingsLogic.cs index 6932b8ba6e..e203ec113f 100644 --- a/OpenRA.Mods.Common/Widgets/Logic/SettingsLogic.cs +++ b/OpenRA.Mods.Common/Widgets/Logic/SettingsLogic.cs @@ -484,6 +484,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic BindCheckboxPref(panel, "PERFTEXT_CHECKBOX", ds, "PerfText"); BindCheckboxPref(panel, "PERFGRAPH_CHECKBOX", ds, "PerfGraph"); BindCheckboxPref(panel, "CHECKUNSYNCED_CHECKBOX", ds, "SyncCheckUnsyncedCode"); + BindCheckboxPref(panel, "CHECKBOTSYNC_CHECKBOX", ds, "SyncCheckBotModuleCode"); BindCheckboxPref(panel, "BOTDEBUG_CHECKBOX", ds, "BotDebug"); BindCheckboxPref(panel, "FETCH_NEWS_CHECKBOX", gs, "FetchNews"); BindCheckboxPref(panel, "LUADEBUG_CHECKBOX", ds, "LuaDebug"); @@ -510,6 +511,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic ds.PerfText = dds.PerfText; ds.PerfGraph = dds.PerfGraph; ds.SyncCheckUnsyncedCode = dds.SyncCheckUnsyncedCode; + ds.SyncCheckBotModuleCode = dds.SyncCheckBotModuleCode; ds.BotDebug = dds.BotDebug; ds.LuaDebug = dds.LuaDebug; ds.SendSystemInformation = dds.SendSystemInformation; diff --git a/mods/cnc/chrome/settings.yaml b/mods/cnc/chrome/settings.yaml index 161c7d194c..c89e5e1f06 100644 --- a/mods/cnc/chrome/settings.yaml +++ b/mods/cnc/chrome/settings.yaml @@ -587,6 +587,13 @@ Container@SETTINGS_PANEL: Height: 20 Font: Regular Text: Check Sync around Unsynced Code + Checkbox@CHECKBOTSYNC_CHECKBOX: + X: 15 + Y: 280 + Width: 300 + Height: 20 + Font: Regular + Text: Check Sync around BotModule Code Checkbox@LUADEBUG_CHECKBOX: X: 310 Y: 220 diff --git a/mods/common/chrome/settings.yaml b/mods/common/chrome/settings.yaml index e816c1a541..ec3cf3619b 100644 --- a/mods/common/chrome/settings.yaml +++ b/mods/common/chrome/settings.yaml @@ -598,6 +598,13 @@ Background@SETTINGS_PANEL: Height: 20 Font: Regular Text: Check Sync around Unsynced Code + Checkbox@CHECKBOTSYNC_CHECKBOX: + X: 15 + Y: 280 + Width: 300 + Height: 20 + Font: Regular + Text: Check Sync around BotModule Code Checkbox@LUADEBUG_CHECKBOX: X: 310 Y: 220