diff options
author | Jesse Plamondon-Willard <Pathoschild@users.noreply.github.com> | 2019-02-08 18:19:28 -0500 |
---|---|---|
committer | Jesse Plamondon-Willard <Pathoschild@users.noreply.github.com> | 2019-02-08 18:19:28 -0500 |
commit | 215574f2b9bb18f98bd9ce208c58e741384aada6 (patch) | |
tree | 3399f7b862d9cf5c908a75b7501e822fc189aa4f /src/SMAPI | |
parent | 63d146b27114d3176411d102667e9300fe87c512 (diff) | |
download | SMAPI-215574f2b9bb18f98bd9ce208c58e741384aada6.tar.gz SMAPI-215574f2b9bb18f98bd9ce208c58e741384aada6.tar.bz2 SMAPI-215574f2b9bb18f98bd9ce208c58e741384aada6.zip |
fix error when swapping maps mid-session for a location with interior doors
Diffstat (limited to 'src/SMAPI')
-rw-r--r-- | src/SMAPI/Metadata/CoreAssetPropagator.cs | 15 |
1 files changed, 14 insertions, 1 deletions
diff --git a/src/SMAPI/Metadata/CoreAssetPropagator.cs b/src/SMAPI/Metadata/CoreAssetPropagator.cs index 53d930f5..a64dc89b 100644 --- a/src/SMAPI/Metadata/CoreAssetPropagator.cs +++ b/src/SMAPI/Metadata/CoreAssetPropagator.cs @@ -2,7 +2,7 @@ using System; using System.Collections.Generic; using System.IO; using System.Linq; -using Microsoft.Xna.Framework; +using System.Reflection; using Microsoft.Xna.Framework.Graphics; using StardewModdingAPI.Framework.Reflection; using StardewValley; @@ -99,8 +99,21 @@ namespace StardewModdingAPI.Metadata { if (!string.IsNullOrWhiteSpace(location.mapPath.Value) && this.GetNormalisedPath(location.mapPath.Value) == key) { + // reload map data this.Reflection.GetMethod(location, "reloadMap").Invoke(); this.Reflection.GetMethod(location, "updateWarps").Invoke(); + + // reload doors + { + Type interiorDoorDictType = Type.GetType($"StardewValley.InteriorDoorDictionary, {Constants.GameAssemblyName}", throwOnError: true); + ConstructorInfo constructor = interiorDoorDictType.GetConstructor(new[] { typeof(GameLocation) }); + if (constructor == null) + throw new InvalidOperationException("Can't reset location doors: constructor not found for InteriorDoorDictionary type."); + object instance = constructor.Invoke(new object[] { location }); + + this.Reflection.GetField<object>(location, "interiorDoors").SetValue(instance); + } + anyChanged = true; } } |