From 34f4c9bdaa2443552954e6226dd64840715c587c Mon Sep 17 00:00:00 2001 From: abcdefg30 Date: Wed, 2 Oct 2019 12:32:24 +0200 Subject: [PATCH] Prevent chronoshifting an empty selection --- OpenRA.Mods.Cnc/Traits/SupportPowers/ChronoshiftPower.cs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/OpenRA.Mods.Cnc/Traits/SupportPowers/ChronoshiftPower.cs b/OpenRA.Mods.Cnc/Traits/SupportPowers/ChronoshiftPower.cs index 75c78a3f8d..6af7c6f3d7 100644 --- a/OpenRA.Mods.Cnc/Traits/SupportPowers/ChronoshiftPower.cs +++ b/OpenRA.Mods.Cnc/Traits/SupportPowers/ChronoshiftPower.cs @@ -318,8 +318,13 @@ namespace OpenRA.Mods.Cnc.Traits bool IsValidTarget(CPos xy) { + // Don't teleport if there are no units in range (either all moved out of range, or none yet moved into range) + var unitsInRange = power.UnitsInRange(sourceLocation); + if (!unitsInRange.Any()) + return false; + var canTeleport = false; - foreach (var unit in power.UnitsInRange(sourceLocation)) + foreach (var unit in unitsInRange) { var targetCell = unit.Location + (xy - sourceLocation); if (manager.Self.Owner.Shroud.IsExplored(targetCell) && unit.Trait().CanChronoshiftTo(unit, targetCell))