From 7e72cd262cef51a72f5062ff221c76e65a97153d Mon Sep 17 00:00:00 2001 From: Paul Chote Date: Sat, 15 Feb 2020 23:14:52 +0000 Subject: [PATCH] Fix FlyAttack invalid target crash. --- .../Activities/Air/FlyAttack.cs | 20 +++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/OpenRA.Mods.Common/Activities/Air/FlyAttack.cs b/OpenRA.Mods.Common/Activities/Air/FlyAttack.cs index e119f4b064..67ab3cf86b 100644 --- a/OpenRA.Mods.Common/Activities/Air/FlyAttack.cs +++ b/OpenRA.Mods.Common/Activities/Air/FlyAttack.cs @@ -222,8 +222,14 @@ namespace OpenRA.Mods.Common.Activities protected override void OnFirstRun(Actor self) { - QueueChild(new Fly(self, target, target.CenterPosition)); - QueueChild(new Fly(self, target, exitRange, WDist.MaxValue, target.CenterPosition)); + // The target may have died while this activity was queued + if (target.IsValidFor(self)) + { + QueueChild(new Fly(self, target, target.CenterPosition)); + QueueChild(new Fly(self, target, exitRange, WDist.MaxValue, target.CenterPosition)); + } + else + Cancel(self); } public override bool Tick(Actor self) @@ -261,8 +267,14 @@ namespace OpenRA.Mods.Common.Activities protected override void OnFirstRun(Actor self) { - QueueChild(new Fly(self, target, target.CenterPosition)); - QueueChild(new Fly(self, target, exitRange, WDist.MaxValue, target.CenterPosition)); + // The target may have died while this activity was queued + if (target.IsValidFor(self)) + { + QueueChild(new Fly(self, target, target.CenterPosition)); + QueueChild(new Fly(self, target, exitRange, WDist.MaxValue, target.CenterPosition)); + } + else + Cancel(self); } public override bool Tick(Actor self)