Add setting to check BotModule sync.

This commit is contained in:
Paul Chote
2018-12-23 22:53:30 +00:00
committed by reaperrr
parent 83e44bee66
commit 601990aa27
5 changed files with 40 additions and 13 deletions

View File

@@ -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;

View File

@@ -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;

View File

@@ -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;

View File

@@ -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

View File

@@ -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