From 49621bebd01c88c223a36fcd85756b81acd94335 Mon Sep 17 00:00:00 2001 From: Paul Chote Date: Fri, 8 Feb 2019 20:29:08 +0000 Subject: [PATCH] Abort activities when we don't know how close to move to a target. --- OpenRA.Mods.Cnc/Activities/LeapAttack.cs | 2 +- OpenRA.Mods.Common/Activities/Attack.cs | 2 +- OpenRA.Mods.Common/Traits/Attack/AttackFollow.cs | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/OpenRA.Mods.Cnc/Activities/LeapAttack.cs b/OpenRA.Mods.Cnc/Activities/LeapAttack.cs index 2155d73928..7c26581289 100644 --- a/OpenRA.Mods.Cnc/Activities/LeapAttack.cs +++ b/OpenRA.Mods.Cnc/Activities/LeapAttack.cs @@ -95,7 +95,7 @@ namespace OpenRA.Mods.Cnc.Activities if (!checkTarget.IsInRange(pos, lastVisibleMaxRange) || checkTarget.IsInRange(pos, lastVisibleMinRange)) { - if (!allowMovement) + if (!allowMovement || lastVisibleMaxRange == WDist.Zero || lastVisibleMaxRange < lastVisibleMinRange) return NextActivity; QueueChild(mobile.MoveWithinRange(target, lastVisibleMinRange, lastVisibleMaxRange, checkTarget.CenterPosition, Color.Red)); diff --git a/OpenRA.Mods.Common/Activities/Attack.cs b/OpenRA.Mods.Common/Activities/Attack.cs index 2403bac50d..782b284d02 100644 --- a/OpenRA.Mods.Common/Activities/Attack.cs +++ b/OpenRA.Mods.Common/Activities/Attack.cs @@ -109,7 +109,7 @@ namespace OpenRA.Mods.Common.Activities if (useLastVisibleTarget) { // We've reached the assumed position but it is not there or we can't move any further - give up - if (checkTarget.IsInRange(pos, lastVisibleMaximumRange) || move == null) + if (checkTarget.IsInRange(pos, lastVisibleMaximumRange) || move == null || lastVisibleMaximumRange == WDist.Zero) return NextActivity; // Move towards the last known position diff --git a/OpenRA.Mods.Common/Traits/Attack/AttackFollow.cs b/OpenRA.Mods.Common/Traits/Attack/AttackFollow.cs index 771908f541..0c601992e0 100644 --- a/OpenRA.Mods.Common/Traits/Attack/AttackFollow.cs +++ b/OpenRA.Mods.Common/Traits/Attack/AttackFollow.cs @@ -268,7 +268,7 @@ namespace OpenRA.Mods.Common.Traits } // We can't move into range, so give up - if (move == null) + if (move == null || maxRange == WDist.Zero || maxRange < minRange) { attack.requestedTarget = Target.Invalid; return NextActivity;