From 561466d822becc3658aa27bd2bed69a0e7660fce Mon Sep 17 00:00:00 2001 From: Ashley Newson Date: Wed, 21 May 2025 01:11:44 +0100 Subject: [PATCH] Fix Path Tiling tool rally confusion and crash If the path being planned by the Path Tiling tool overlaps itself such that a later rally intersects an earlier line, attempting to interact with this later rally caused the UI to instead select the rally associated with the earlier line. This at best leads to user confusion and at worst leads to a crash if they then drag the rally over another rally. This commit fixes the UI logic to correctly identify the rally being clicked on. --- .../EditorBrushes/EditorTilingPathBrush.cs | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/OpenRA.Mods.Common/EditorBrushes/EditorTilingPathBrush.cs b/OpenRA.Mods.Common/EditorBrushes/EditorTilingPathBrush.cs index 908d6b99f7..a0f566adc6 100644 --- a/OpenRA.Mods.Common/EditorBrushes/EditorTilingPathBrush.cs +++ b/OpenRA.Mods.Common/EditorBrushes/EditorTilingPathBrush.cs @@ -106,10 +106,12 @@ namespace OpenRA.Mods.Common.Widgets var isInside = points.Select(p => p.CPos).Contains(cpos); var isRally = plan.Rallies.Contains(cpos); var rallyIndex = - points - .Where(p => p.CPos == cpos) - .Select(p => p.RallyIndex) - .FirstOrDefault(0); + isRally + ? plan.Rallies.TakeWhile(r => r != cpos).Count() + : points + .Where(p => p.CPos == cpos) + .Select(p => p.RallyIndex) + .FirstOrDefault(0); var isStartDirector = plan.AutoStart != Direction.None && cpos == plan.FirstPoint - plan.AutoStart.ToCVec();