Skip to content

Commit

Permalink
Fix Resupply closeEnough bugs
Browse files Browse the repository at this point in the history
Fixes that
- RepairableNear actors wouldn't move close enough
- isCloseEnough would return 'true' even if the host
  is invalid.
  • Loading branch information
reaperrr authored and pchote committed Aug 22, 2019
1 parent 8457dfd commit e71001f
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion OpenRA.Mods.Common/Activities/Resupply.cs
Expand Up @@ -84,7 +84,20 @@ public override bool Tick(Actor self)
}

var isHostInvalid = host.Type != TargetType.Actor || !host.Actor.IsInWorld;
var isCloseEnough = closeEnough < WDist.Zero || (!isHostInvalid && (host.CenterPosition - self.CenterPosition).HorizontalLengthSquared <= closeEnough.LengthSquared);
var isCloseEnough = false;
if (!isHostInvalid)
{
// Negative means there's no distance limit.
// If RepairableNear, use TargetablePositions instead of CenterPosition
// to ensure the actor moves close enough to the host.
// Otherwise check against host CenterPosition.
if (closeEnough < WDist.Zero)
isCloseEnough = true;
else if (repairableNear != null)
isCloseEnough = host.IsInRange(self.CenterPosition, closeEnough);
else
isCloseEnough = (host.CenterPosition - self.CenterPosition).HorizontalLengthSquared <= closeEnough.LengthSquared;
}

// This ensures transports are also cancelled when the host becomes invalid
if (!IsCanceling && isHostInvalid)
Expand Down

0 comments on commit e71001f

Please sign in to comment.