From 4d3db0d45488c2cf19afcb3aa5b2ce2691553291 Mon Sep 17 00:00:00 2001 From: Paul Chote Date: Fri, 4 Jan 2019 17:52:33 +0000 Subject: [PATCH] Fix invalid target crash if Leap target dies. --- OpenRA.Mods.Cnc/Activities/Leap.cs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/OpenRA.Mods.Cnc/Activities/Leap.cs b/OpenRA.Mods.Cnc/Activities/Leap.cs index a1a544754e..bb059f1892 100644 --- a/OpenRA.Mods.Cnc/Activities/Leap.cs +++ b/OpenRA.Mods.Cnc/Activities/Leap.cs @@ -35,6 +35,7 @@ namespace OpenRA.Mods.Cnc.Activities bool canceled = false; bool jumpComplete = false; int ticks = 0; + WPos targetPosition; public Leap(Actor self, Target target, Mobile mobile, Mobile targetMobile, int speed, AttackLeap attack, EdibleByLeap edible) { @@ -65,6 +66,7 @@ namespace OpenRA.Mods.Cnc.Activities if (canceled) return; + targetPosition = target.CenterPosition; attack.GrantLeapCondition(self); } @@ -83,7 +85,10 @@ namespace OpenRA.Mods.Cnc.Activities return this; } - var position = length > 1 ? WPos.Lerp(origin, target.CenterPosition, ticks, length - 1) : target.CenterPosition; + if (target.Type != TargetType.Invalid) + targetPosition = target.CenterPosition; + + var position = length > 1 ? WPos.Lerp(origin, targetPosition, ticks, length - 1) : targetPosition; mobile.SetVisualPosition(self, position); // We are at the destination