From b1b74c13c37d68e317f68dee643d0353a914d1e1 Mon Sep 17 00:00:00 2001 From: abcdefg30 Date: Fri, 7 Feb 2020 12:38:57 +0100 Subject: [PATCH] Ensure that we never tick an activity before calling OnFirstRun --- OpenRA.Game/Activities/Activity.cs | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/OpenRA.Game/Activities/Activity.cs b/OpenRA.Game/Activities/Activity.cs index b4115edd5e..452267bd65 100644 --- a/OpenRA.Game/Activities/Activity.cs +++ b/OpenRA.Game/Activities/Activity.cs @@ -83,6 +83,7 @@ namespace OpenRA.Activities public bool ChildHasPriority { get; protected set; } public bool IsCanceling { get { return State == ActivityState.Canceling; } } bool finishing; + bool firstRunCompleted; bool lastRun; public Activity() @@ -99,9 +100,13 @@ namespace OpenRA.Activities if (State == ActivityState.Queued) { OnFirstRun(self); + firstRunCompleted = true; State = ActivityState.Active; } + if (!firstRunCompleted) + throw new InvalidOperationException("Actor {0} attempted to tick activity {1} before running its OnFirstRun method.".F(self, GetType())); + // Only run the parent tick when the child is done. // We must always let the child finish on its own before continuing. if (ChildHasPriority)