Skip to content

Commit

Permalink
Fix crash in TSEditorResourceLayer when adding resources.
Browse files Browse the repository at this point in the history
Ensure cells are within map bounds when checking if adjacent cells should be cleared during resource placement.
  • Loading branch information
RoosterDragon authored and abcdefg30 committed Mar 26, 2022
1 parent e685731 commit ea243b8
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions OpenRA.Mods.Cnc/Traits/World/TSEditorResourceLayer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,9 @@ protected override int AddResource(string resourceType, CPos cell, int amount =
var resourceIsVeins = resourceType == info.VeinType;
foreach (var c in Common.Util.ExpandFootprint(cell, false))
{
if (!Map.Resources.Contains(c))
continue;

var resourceIndex = Map.Resources[c].Type;
if (resourceIndex == 0 || !ResourceTypesByIndex.TryGetValue(resourceIndex, out var neighourResourceType))
neighourResourceType = null;
Expand Down

0 comments on commit ea243b8

Please sign in to comment.