summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJesse Plamondon-Willard <Pathoschild@users.noreply.github.com>2022-04-19 22:08:34 -0400
committerJesse Plamondon-Willard <Pathoschild@users.noreply.github.com>2022-04-19 22:08:34 -0400
commitf0645c59931f56415999b9befe473f5af642a5ce (patch)
tree3ae645a81bf71bd305f29c48b8fee92d37863a13 /src
parent9939061615c41fabca004bf8f5b6f2b018a40b06 (diff)
downloadSMAPI-f0645c59931f56415999b9befe473f5af642a5ce.tar.gz
SMAPI-f0645c59931f56415999b9befe473f5af642a5ce.tar.bz2
SMAPI-f0645c59931f56415999b9befe473f5af642a5ce.zip
fix null reference when adding new layers in a map patch
Diffstat (limited to 'src')
-rw-r--r--src/SMAPI/Framework/Content/AssetDataForMap.cs11
1 files changed, 9 insertions, 2 deletions
diff --git a/src/SMAPI/Framework/Content/AssetDataForMap.cs b/src/SMAPI/Framework/Content/AssetDataForMap.cs
index 8674461e..b8722ead 100644
--- a/src/SMAPI/Framework/Content/AssetDataForMap.cs
+++ b/src/SMAPI/Framework/Content/AssetDataForMap.cs
@@ -99,8 +99,15 @@ namespace StardewModdingAPI.Framework.Content
}
// get target layers
- IDictionary<Layer, Layer> sourceToTargetLayers = source.Layers.ToDictionary(p => p, p => target.GetLayer(p.Id));
- HashSet<Layer> orphanedTargetLayers = new HashSet<Layer>(target.Layers.Except(sourceToTargetLayers.Values));
+ Dictionary<Layer, Layer> sourceToTargetLayers =
+ (
+ from sourceLayer in source.Layers
+ let targetLayer = target.GetLayer(sourceLayer.Id)
+ where targetLayer != null
+ select (sourceLayer, targetLayer)
+ )
+ .ToDictionary(p => p.sourceLayer, p => p.targetLayer);
+ HashSet<Layer> orphanedTargetLayers = new(target.Layers.Except(sourceToTargetLayers.Values));
// apply tiles
bool replaceAll = patchMode == PatchMapMode.Replace;