Skip to content

Commit bd951d8

Browse files
reaperrrpchote
authored andcommitted
Fix FindActorsOnLine overscan
1 parent f520b37 commit bd951d8

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

OpenRA.Mods.Common/WorldExtensions.cs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,11 @@ public static IEnumerable<Actor> FindActorsOnLine(this World world, WPos lineSta
3232
// Then we iterate over this list, and find all actors for which their health radius is at least within lineWidth of the line.
3333
// For actors without a health radius, we simply check their center point.
3434
// The square in which we select all actors must be large enough to encompass the entire line's width.
35-
var xDir = Math.Sign(lineEnd.X - lineStart.X);
36-
var yDir = Math.Sign(lineEnd.Y - lineStart.Y);
35+
// xDir and yDir must never be 0, otherwise the overscan will be 0 in the respective direction.
36+
var xDiff = lineEnd.X - lineStart.X;
37+
var yDiff = lineEnd.Y - lineStart.Y;
38+
var xDir = xDiff < 0 ? -1 : 1;
39+
var yDir = yDiff < 0 ? -1 : 1;
3740

3841
var dir = new WVec(xDir, yDir, 0);
3942
var overselect = dir * (1024 + lineWidth.Length + targetExtraSearchRadius.Length);

0 commit comments

Comments
 (0)