Skip to content

Commit

Permalink
Fix a crash in the TSResourceLayer neighbour validation
Browse files Browse the repository at this point in the history
  • Loading branch information
abcdefg30 authored and reaperrr committed Nov 11, 2021
1 parent 430c7a4 commit 31cec0c
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions OpenRA.Mods.Cnc/Traits/World/TSResourceLayer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -74,13 +74,19 @@ void INotifyActorDisposing.Disposing(Actor self)

bool IsValidResourceNeighbour(CPos cell, CPos neighbour)
{
if (!Map.Contains(neighbour))
return false;

// Non-vein resources are not allowed in the cardinal neighbours to
// an already existing vein cell
return Content[neighbour].Type != info.VeinType;
}

bool IsValidVeinNeighbour(CPos cell, CPos neighbour)
{
if (!Map.Contains(neighbour))
return false;

// Cell is automatically valid if it contains a veinhole actor
if (veinholeCells.Contains(neighbour))
return true;
Expand Down Expand Up @@ -112,8 +118,7 @@ protected override bool AllowResourceAt(string resourceType, CPos cell)

// Ensure there is space for the vein border tiles (not needed on ramps)
var check = resourceType == info.VeinType ? (Func<CPos, CPos, bool>)IsValidVeinNeighbour : IsValidResourceNeighbour;
var blockedByNeighbours = Map.Ramp[cell] == 0 && !Common.Util.ExpandFootprint(cell, false)
.All(c => check(cell, c));
var blockedByNeighbours = Map.Ramp[cell] == 0 && !Common.Util.ExpandFootprint(cell, false).All(c => check(cell, c));

return !blockedByNeighbours && (resourceType == info.VeinType || !BuildingInfluence.AnyBuildingAt(cell));
}
Expand Down

0 comments on commit 31cec0c

Please sign in to comment.