From fa415543092430cae1db773563f48646d25e4a82 Mon Sep 17 00:00:00 2001 From: reaperrr Date: Wed, 17 Jul 2019 00:19:47 +0200 Subject: [PATCH] Fix actors resupplying even if too far from resupplier --- OpenRA.Mods.Common/Activities/Resupply.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/OpenRA.Mods.Common/Activities/Resupply.cs b/OpenRA.Mods.Common/Activities/Resupply.cs index 8573cc551b..0b27c2b4ac 100644 --- a/OpenRA.Mods.Common/Activities/Resupply.cs +++ b/OpenRA.Mods.Common/Activities/Resupply.cs @@ -79,7 +79,8 @@ namespace OpenRA.Mods.Common.Activities // HACK: If the activity is cancelled while we're already resupplying (or about to start resupplying), // move actor outside the resupplier footprint. // TODO: This check is nowhere near robust enough, and should be rewritten. - if (IsCanceling && host.IsInRange(self.CenterPosition, closeEnough)) + var isCloseEnough = closeEnough.LengthSquared == 0 || (host.CenterPosition - self.CenterPosition).HorizontalLengthSquared <= closeEnough.LengthSquared; + if (IsCanceling && isCloseEnough) { foreach (var notifyResupply in notifyResupplies) notifyResupply.ResupplyTick(host.Actor, self, ResupplyType.None); @@ -95,8 +96,7 @@ namespace OpenRA.Mods.Common.Activities return true; } - else if (activeResupplyTypes != 0 && aircraft == null && - (closeEnough.LengthSquared > 0 && !host.IsInRange(self.CenterPosition, closeEnough))) + else if (activeResupplyTypes != 0 && aircraft == null && !isCloseEnough) { var targetCell = self.World.Map.CellContaining(host.Actor.CenterPosition);