Check for and fix non-unit MultiBrush segment steps

TilingPath's algorithms are designed on the assumption that MultiBrush
segments use unit steps in their point sequences. Non-unit
sequences can result in incorrect or suboptimal tilings.

This change ensures point sequences are validated for unit steps, and
fixes a non-compliant cliff tile across all tilesets.
This commit is contained in:
Ashley Newson
2025-05-24 22:22:26 +01:00
committed by Gustas Kažukauskas
parent 7538943f59
commit 2a0e787ae7
8 changed files with 17 additions and 7 deletions

View File

@@ -189,9 +189,19 @@ namespace OpenRA.Mods.Common.MapGenerator
.Split(',', StringSplitOptions.RemoveEmptyEntries);
if (parts.Length % 2 != 0)
FieldLoader.InvalidValueAction(value, typeof(int2[]), "Points");
var points = new CVec[parts.Length / 2];
for (var i = 0; i < points.Length; i++)
{
points[i] = new CVec(Exts.ParseInt32Invariant(parts[2 * i]), Exts.ParseInt32Invariant(parts[2 * i + 1]));
if (i > 0)
{
var step = points[i] - points[i - 1];
if (Math.Abs(step.X) + Math.Abs(step.Y) != 1)
throw new YamlException($"Points sequence {value} has non-unit steps");
}
}
Points = [.. points];
}
}

View File

@@ -2232,7 +2232,7 @@ MultiBrushCollections:
Start: Cliff.L
Inner: Cliff
End: Cliff.L
Points: 2,1, 1,1, 0,2
Points: 2,1, 1,1, 1,2, 0,2
MultiBrush@19:
Template: 19
Segment:

View File

@@ -1879,7 +1879,7 @@ MultiBrushCollections:
Start: Cliff.L
Inner: Cliff
End: Cliff.L
Points: 2,1, 1,1, 0,2
Points: 2,1, 1,1, 1,2, 0,2
MultiBrush@19:
Template: 19
Segment:

View File

@@ -1880,7 +1880,7 @@ MultiBrushCollections:
Start: Cliff.L
Inner: Cliff
End: Cliff.L
Points: 2,1, 1,1, 0,2
Points: 2,1, 1,1, 1,2, 0,2
MultiBrush@19:
Template: 19
Segment:

View File

@@ -1915,7 +1915,7 @@ MultiBrushCollections:
Start: Cliff.L
Inner: Cliff
End: Cliff.L
Points: 2,1, 1,1, 0,2
Points: 2,1, 1,1, 1,2, 0,2
MultiBrush@19:
Template: 19
Segment:

View File

@@ -3475,7 +3475,7 @@ MultiBrushCollections:
Start: Cliff.L
Inner: Cliff
End: Cliff.L
Points: 2,1, 1,1, 0,2
Points: 2,1, 1,1, 1,2, 0,2
MultiBrush@186:
Template: 186
Segment:

View File

@@ -4015,7 +4015,7 @@ MultiBrushCollections:
Start: Cliff.L
Inner: Cliff
End: Cliff.L
Points: 2,1, 1,1, 0,2
Points: 2,1, 1,1, 1,2, 0,2
MultiBrush@141:
Template: 141
Segment:

View File

@@ -4475,7 +4475,7 @@ MultiBrushCollections:
Start: Cliff.L
Inner: Cliff
End: Cliff.L
Points: 2,1, 1,1, 0,2
Points: 2,1, 1,1, 1,2, 0,2
MultiBrush@141:
Template: 141
Segment: