Always check if activity state is Done.

This commit is contained in:
tovl
2019-05-12 19:11:34 +02:00
committed by teinarss
parent 714b09ac4f
commit 09c1611239
5 changed files with 5 additions and 30 deletions

View File

@@ -31,13 +31,7 @@ namespace OpenRA.Activities
{ {
public ActivityState State { get; private set; } public ActivityState State { get; private set; }
Activity childActivity; protected Activity ChildActivity { get; private set; }
protected Activity ChildActivity
{
get { return childActivity != null && childActivity.State < ActivityState.Done ? childActivity : null; }
set { childActivity = value; }
}
public Activity NextActivity { get; protected set; } public Activity NextActivity { get; protected set; }
public bool IsInterruptible { get; protected set; } public bool IsInterruptible { get; protected set; }
@@ -52,7 +46,7 @@ namespace OpenRA.Activities
public Activity TickOuter(Actor self) public Activity TickOuter(Actor self)
{ {
if (State == ActivityState.Done && Game.Settings.Debug.StrictActivityChecking) if (State == ActivityState.Done)
throw new InvalidOperationException("Actor {0} attempted to tick activity {1} after it had already completed.".F(self, GetType())); throw new InvalidOperationException("Actor {0} attempted to tick activity {1} after it had already completed.".F(self, GetType()));
if (State == ActivityState.Queued) if (State == ActivityState.Queued)
@@ -188,14 +182,14 @@ namespace OpenRA.Activities
while (act != null) while (act != null)
{ {
yield return act.GetType().Name; yield return act.GetType().Name;
act = act.childActivity; act = act.ChildActivity;
} }
} }
public IEnumerable<T> ActivitiesImplementing<T>(bool includeChildren = true) where T : IActivityInterface public IEnumerable<T> ActivitiesImplementing<T>(bool includeChildren = true) where T : IActivityInterface
{ {
if (includeChildren && childActivity != null) if (includeChildren && ChildActivity != null)
foreach (var a in childActivity.ActivitiesImplementing<T>()) foreach (var a in ChildActivity.ActivitiesImplementing<T>())
yield return a; yield return a;
if (this is T) if (this is T)

View File

@@ -128,9 +128,6 @@ namespace OpenRA
[Desc("Throw an exception if the world sync hash changes while evaluating BotModules.")] [Desc("Throw an exception if the world sync hash changes while evaluating BotModules.")]
public bool SyncCheckBotModuleCode = false; public bool SyncCheckBotModuleCode = false;
[Desc("Throw an exception if an actor activity is ticked after it has been marked as completed.")]
public bool StrictActivityChecking = false;
} }
public class GraphicSettings public class GraphicSettings

View File

@@ -556,7 +556,6 @@ namespace OpenRA.Mods.Common.Widgets.Logic
BindCheckboxPref(panel, "REPLAY_COMMANDS_CHECKBOX", ds, "EnableDebugCommandsInReplays"); BindCheckboxPref(panel, "REPLAY_COMMANDS_CHECKBOX", ds, "EnableDebugCommandsInReplays");
BindCheckboxPref(panel, "CHECKUNSYNCED_CHECKBOX", ds, "SyncCheckUnsyncedCode"); BindCheckboxPref(panel, "CHECKUNSYNCED_CHECKBOX", ds, "SyncCheckUnsyncedCode");
BindCheckboxPref(panel, "CHECKBOTSYNC_CHECKBOX", ds, "SyncCheckBotModuleCode"); BindCheckboxPref(panel, "CHECKBOTSYNC_CHECKBOX", ds, "SyncCheckBotModuleCode");
BindCheckboxPref(panel, "STRICTACTIVITY_CHECKBOX", ds, "StrictActivityChecking");
panel.Get("DEBUG_OPTIONS").IsVisible = () => ds.DisplayDeveloperSettings; panel.Get("DEBUG_OPTIONS").IsVisible = () => ds.DisplayDeveloperSettings;
panel.Get("DEBUG_HIDDEN_LABEL").IsVisible = () => !ds.DisplayDeveloperSettings; panel.Get("DEBUG_HIDDEN_LABEL").IsVisible = () => !ds.DisplayDeveloperSettings;

View File

@@ -659,13 +659,6 @@ Container@SETTINGS_PANEL:
Height: 20 Height: 20
Font: Regular Font: Regular
Text: Enable Debug Commands in Replays Text: Enable Debug Commands in Replays
Checkbox@STRICTACTIVITY_CHECKBOX:
X: 310
Y: 280
Width: 300
Height: 20
Font: Regular
Text: Strict Activity checking
Button@BACK_BUTTON: Button@BACK_BUTTON:
Key: escape Key: escape
Y: 393 Y: 393

View File

@@ -669,11 +669,3 @@ Background@SETTINGS_PANEL:
Height: 20 Height: 20
Font: Regular Font: Regular
Text: Enable Debug Commands in Replays Text: Enable Debug Commands in Replays
Checkbox@STRICTACTIVITY_CHECKBOX:
X: 310
Y: 280
Width: 300
Height: 20
Font: Regular
Text: Strict Activity checking
TooltipContainer@TOOLTIP_CONTAINER: