From b1c63a4752ff7b507be4f33465025ecf7283fdb9 Mon Sep 17 00:00:00 2001 From: reaperrr Date: Thu, 24 Aug 2017 12:45:51 +0200 Subject: [PATCH] Fix FindActorsOnLine overscan --- OpenRA.Mods.Common/WorldExtensions.cs | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/OpenRA.Mods.Common/WorldExtensions.cs b/OpenRA.Mods.Common/WorldExtensions.cs index b0c6d903e0..b2252dc16d 100644 --- a/OpenRA.Mods.Common/WorldExtensions.cs +++ b/OpenRA.Mods.Common/WorldExtensions.cs @@ -32,8 +32,11 @@ namespace OpenRA.Mods.Common // Then we iterate over this list, and find all actors for which their health radius is at least within lineWidth of the line. // For actors without a health radius, we simply check their center point. // The square in which we select all actors must be large enough to encompass the entire line's width. - var xDir = Math.Sign(lineEnd.X - lineStart.X); - var yDir = Math.Sign(lineEnd.Y - lineStart.Y); + // xDir and yDir must never be 0, otherwise the overscan will be 0 in the respective direction. + var xDiff = lineEnd.X - lineStart.X; + var yDiff = lineEnd.Y - lineStart.Y; + var xDir = xDiff < 0 ? -1 : 1; + var yDir = yDiff < 0 ? -1 : 1; var dir = new WVec(xDir, yDir, 0); var overselect = dir * (1024 + lineWidth.Length + targetExtraSearchRadius.Length);