From ea243b85583596750c7881f0ab5ca44d30e9be7d Mon Sep 17 00:00:00 2001 From: RoosterDragon Date: Sat, 26 Mar 2022 14:48:44 +0000 Subject: [PATCH] Fix crash in TSEditorResourceLayer when adding resources. Ensure cells are within map bounds when checking if adjacent cells should be cleared during resource placement. --- OpenRA.Mods.Cnc/Traits/World/TSEditorResourceLayer.cs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/OpenRA.Mods.Cnc/Traits/World/TSEditorResourceLayer.cs b/OpenRA.Mods.Cnc/Traits/World/TSEditorResourceLayer.cs index 496b3a6a28f0..92757890bcbc 100644 --- a/OpenRA.Mods.Cnc/Traits/World/TSEditorResourceLayer.cs +++ b/OpenRA.Mods.Cnc/Traits/World/TSEditorResourceLayer.cs @@ -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;