From f945349ed40b770c1f7788f659d4ef3980abe3ff Mon Sep 17 00:00:00 2001 From: David Camp Date: Fri, 15 Jan 2021 18:48:29 -0500 Subject: (feat) Disable Mod rewrites if requested --- src/SMAPI/Metadata/InstructionMetadata.cs | 25 ++++++++++++++----------- 1 file changed, 14 insertions(+), 11 deletions(-) (limited to 'src/SMAPI/Metadata') diff --git a/src/SMAPI/Metadata/InstructionMetadata.cs b/src/SMAPI/Metadata/InstructionMetadata.cs index 2c1e14ce..1816e7f9 100644 --- a/src/SMAPI/Metadata/InstructionMetadata.cs +++ b/src/SMAPI/Metadata/InstructionMetadata.cs @@ -27,29 +27,32 @@ namespace StardewModdingAPI.Metadata /// Get rewriters which detect or fix incompatible CIL instructions in mod assemblies. /// Whether to detect paranoid mode issues. /// Whether the assembly was rewritten for crossplatform compatibility. - public IEnumerable GetHandlers(bool paranoidMode, bool platformChanged) + /// Whether to return Rewriters + public IEnumerable GetHandlers(bool paranoidMode, bool platformChanged, bool rewriteMods) { /**** ** rewrite CIL to fix incompatible code ****/ // rewrite for crossplatform compatibility - if (platformChanged) - yield return new MethodParentRewriter(typeof(SpriteBatch), typeof(SpriteBatchFacade)); + if (rewriteMods) + { + if (platformChanged) + yield return new MethodParentRewriter(typeof(SpriteBatch), typeof(SpriteBatchFacade)); - // rewrite for Stardew Valley 1.5 - yield return new FieldReplaceRewriter(typeof(DecoratableLocation), "furniture", typeof(GameLocation), nameof(GameLocation.furniture)); - yield return new FieldReplaceRewriter(typeof(Farm), "resourceClumps", typeof(GameLocation), nameof(GameLocation.resourceClumps)); - yield return new FieldReplaceRewriter(typeof(MineShaft), "resourceClumps", typeof(GameLocation), nameof(GameLocation.resourceClumps)); + // rewrite for Stardew Valley 1.5 + yield return new FieldReplaceRewriter(typeof(DecoratableLocation), "furniture", typeof(GameLocation), nameof(GameLocation.furniture)); + yield return new FieldReplaceRewriter(typeof(Farm), "resourceClumps", typeof(GameLocation), nameof(GameLocation.resourceClumps)); + yield return new FieldReplaceRewriter(typeof(MineShaft), "resourceClumps", typeof(GameLocation), nameof(GameLocation.resourceClumps)); - // heuristic rewrites - yield return new HeuristicFieldRewriter(this.ValidateReferencesToAssemblies); - yield return new HeuristicMethodRewriter(this.ValidateReferencesToAssemblies); + // heuristic rewrites + yield return new HeuristicFieldRewriter(this.ValidateReferencesToAssemblies); + yield return new HeuristicMethodRewriter(this.ValidateReferencesToAssemblies); #if HARMONY_2 // rewrite for SMAPI 3.6 (Harmony 1.x => 2.0 update) yield return new Harmony1AssemblyRewriter(); #endif - + } /**** ** detect mod issues ****/ -- cgit From 666f7ad8f9ad431c3f007d84228207e13d2ddbbc Mon Sep 17 00:00:00 2001 From: Jesse Plamondon-Willard Date: Fri, 15 Jan 2021 18:48:29 -0500 Subject: tweak recent changes, update release notes --- docs/release-notes.md | 3 +++ src/SMAPI/Framework/Logging/LogManager.cs | 10 +++++----- src/SMAPI/Framework/ModLoading/AssemblyLoader.cs | 4 ++-- src/SMAPI/Framework/Models/SConfig.cs | 9 +++++---- src/SMAPI/Metadata/InstructionMetadata.cs | 7 ++++--- src/SMAPI/SMAPI.config.json | 12 ++++++------ 6 files changed, 25 insertions(+), 20 deletions(-) (limited to 'src/SMAPI/Metadata') diff --git a/docs/release-notes.md b/docs/release-notes.md index 7347560e..fabe7572 100644 --- a/docs/release-notes.md +++ b/docs/release-notes.md @@ -8,6 +8,9 @@ --> ## Upcoming release +* For modders: + * Added an option to disable rewriting mods for compatibility (thanks to Bpendragon!). This may prevent older mods from loading, but bypasses a Visual Studio crash when debugging. + * For the Error Handler mod: * Added in SMAPI 3.9. This has vanilla error-handling that was previously added by SMAPI directly. That simplifies the core SMAPI logic, and lets players or modders disable it if needed. diff --git a/src/SMAPI/Framework/Logging/LogManager.cs b/src/SMAPI/Framework/Logging/LogManager.cs index cc573427..ff00cff7 100644 --- a/src/SMAPI/Framework/Logging/LogManager.cs +++ b/src/SMAPI/Framework/Logging/LogManager.cs @@ -208,7 +208,7 @@ namespace StardewModdingAPI.Framework.Logging // show update alert if (File.Exists(Constants.UpdateMarker)) { - string[] rawUpdateFound = File.ReadAllText(Constants.UpdateMarker).Split(new [] { '|' }, 2); + string[] rawUpdateFound = File.ReadAllText(Constants.UpdateMarker).Split(new[] { '|' }, 2); if (SemanticVersion.TryParse(rawUpdateFound[0], out ISemanticVersion updateFound)) { if (Constants.ApiVersion.IsPrerelease() && updateFound.IsNewerThan(Constants.ApiVersion)) @@ -286,15 +286,15 @@ namespace StardewModdingAPI.Framework.Logging /// Log details for settings that don't match the default. /// Whether to enable full console output for developers. /// Whether to check for newer versions of SMAPI and mods on startup. - /// ///Whether to rewrite mods, might need to be false to hook up to the Visual Studio Debugger. + /// Whether to rewrite mods for compatibility. public void LogSettingsHeader(bool isDeveloperMode, bool checkForUpdates, bool rewriteMods) { if (isDeveloperMode) - this.Monitor.Log($"You have SMAPI for developers, so the console will be much more verbose. You can disable developer mode by installing the non-developer version of SMAPI, or by editing {Constants.ApiConfigPath}.", LogLevel.Info); + this.Monitor.Log("You have SMAPI for developers, so the console will be much more verbose. You can disable developer mode by installing the non-developer version of SMAPI.", LogLevel.Info); if (!checkForUpdates) - this.Monitor.Log($"You configured SMAPI to not check for updates. Running an old version of SMAPI is not recommended. You can enable update checks by reinstalling SMAPI or editing {Constants.ApiConfigPath}.", LogLevel.Warn); + this.Monitor.Log("You configured SMAPI to not check for updates. Running an old version of SMAPI is not recommended. You can enable update checks by reinstalling SMAPI.", LogLevel.Warn); if (!rewriteMods) - this.Monitor.Log($"You configured SMAPI to not rewrite potentially broken mods. This is not reccomended except in certain circumstances such as attaching to the Visual Studio debugger. You can enable mod rewrites by reinstalling SMAPI or editing {Constants.ApiConfigPath}.", LogLevel.Warn); + this.Monitor.Log("You configured SMAPI to not rewrite broken mods. Many older mods may fail to load. You can undo this by reinstalling SMAPI.", LogLevel.Warn); if (!this.Monitor.WriteToConsole) this.Monitor.Log("Writing to the terminal is disabled because the --no-terminal argument was received. This usually means launching the terminal failed.", LogLevel.Warn); this.Monitor.VerboseLog("Verbose logging enabled."); diff --git a/src/SMAPI/Framework/ModLoading/AssemblyLoader.cs b/src/SMAPI/Framework/ModLoading/AssemblyLoader.cs index d6a32621..4fae0f44 100644 --- a/src/SMAPI/Framework/ModLoading/AssemblyLoader.cs +++ b/src/SMAPI/Framework/ModLoading/AssemblyLoader.cs @@ -37,7 +37,7 @@ namespace StardewModdingAPI.Framework.ModLoading /// The objects to dispose as part of this instance. private readonly HashSet Disposables = new HashSet(); - /// Whether mods should be re-writen for compatibility. + /// Whether to rewrite mods for compatibility. private readonly bool RewriteMods; @@ -48,7 +48,7 @@ namespace StardewModdingAPI.Framework.ModLoading /// The current game platform. /// Encapsulates monitoring and logging. /// Whether to detect paranoid mode issues. - /// Whether to rewrite potentially broken mods or not. + /// Whether to rewrite mods for compatibility. public AssemblyLoader(Platform targetPlatform, IMonitor monitor, bool paranoidMode, bool rewriteMods) { this.Monitor = monitor; diff --git a/src/SMAPI/Framework/Models/SConfig.cs b/src/SMAPI/Framework/Models/SConfig.cs index a5b27c17..dea08717 100644 --- a/src/SMAPI/Framework/Models/SConfig.cs +++ b/src/SMAPI/Framework/Models/SConfig.cs @@ -28,6 +28,7 @@ namespace StardewModdingAPI.Framework.Models private static readonly HashSet DefaultSuppressUpdateChecks = new HashSet(StringComparer.OrdinalIgnoreCase) { "SMAPI.ConsoleCommands", + "SMAPI.ErrorHandler", "SMAPI.SaveBackup" }; @@ -56,6 +57,9 @@ namespace StardewModdingAPI.Framework.Models /// Whether SMAPI should log more information about the game context. public bool VerboseLogging { get; set; } + /// Whether SMAPI should rewrite mods for compatibility. + public bool RewriteMods { get; set; } = (bool)SConfig.DefaultValues[nameof(SConfig.RewriteMods)]; + /// Whether SMAPI should log network traffic. Best combined with , which includes network metadata. public bool LogNetworkTraffic { get; set; } @@ -65,14 +69,11 @@ namespace StardewModdingAPI.Framework.Models /// The mod IDs SMAPI should ignore when performing update checks or validating update keys. public string[] SuppressUpdateChecks { get; set; } - /// Whether to rewrite mods for compatibility. Should only be set to false to facilitate joining to the Visual Studio Debugger. - public bool RewriteMods { get; set; } = (bool)SConfig.DefaultValues[nameof(SConfig.RewriteMods)]; - /******** ** Public methods ********/ - /// Get the settings which have been customised by the player. + /// Get the settings which have been customized by the player. public IDictionary GetCustomSettings() { IDictionary custom = new Dictionary(); diff --git a/src/SMAPI/Metadata/InstructionMetadata.cs b/src/SMAPI/Metadata/InstructionMetadata.cs index 1816e7f9..d1699636 100644 --- a/src/SMAPI/Metadata/InstructionMetadata.cs +++ b/src/SMAPI/Metadata/InstructionMetadata.cs @@ -27,7 +27,7 @@ namespace StardewModdingAPI.Metadata /// Get rewriters which detect or fix incompatible CIL instructions in mod assemblies. /// Whether to detect paranoid mode issues. /// Whether the assembly was rewritten for crossplatform compatibility. - /// Whether to return Rewriters + /// Whether to get handlers which rewrite mods for compatibility. public IEnumerable GetHandlers(bool paranoidMode, bool platformChanged, bool rewriteMods) { /**** @@ -49,10 +49,11 @@ namespace StardewModdingAPI.Metadata yield return new HeuristicMethodRewriter(this.ValidateReferencesToAssemblies); #if HARMONY_2 - // rewrite for SMAPI 3.6 (Harmony 1.x => 2.0 update) - yield return new Harmony1AssemblyRewriter(); + // rewrite for SMAPI 3.x (Harmony 1.x => 2.0 update) + yield return new Harmony1AssemblyRewriter(); #endif } + /**** ** detect mod issues ****/ diff --git a/src/SMAPI/SMAPI.config.json b/src/SMAPI/SMAPI.config.json index 7b9f76d4..7a710f14 100644 --- a/src/SMAPI/SMAPI.config.json +++ b/src/SMAPI/SMAPI.config.json @@ -33,6 +33,12 @@ copy all the settings, or you may cause bugs due to overridden changes in future */ "DeveloperMode": true, + /** + * Whether SMAPI should rewrite mods for compatibility. This may prevent older mods from + * loading, but bypasses a Visual Studio crash when debugging. + */ + "RewriteMods": true, + /** * Whether to add a section to the 'mod issues' list for mods which directly use potentially * sensitive .NET APIs like file or shell access. Note that many mods do this legitimately as @@ -68,12 +74,6 @@ copy all the settings, or you may cause bugs due to overridden changes in future */ "LogNetworkTraffic": false, - /** - * Whether SMAPI should rewrite mods for compatibility. - * Note: This is best left to true unless you are attempting to hook into the Visual Studio Debugger - */ - "RewriteMods": true, - /** * The colors to use for text written to the SMAPI console. * -- cgit From 47df90f67cab0f1903f0214fed4795c8bd181fe0 Mon Sep 17 00:00:00 2001 From: Jesse Plamondon-Willard Date: Mon, 18 Jan 2021 18:19:46 -0500 Subject: merge sections in asset propagator --- src/SMAPI/Metadata/CoreAssetPropagator.cs | 92 +++++++++++++++---------------- 1 file changed, 46 insertions(+), 46 deletions(-) (limited to 'src/SMAPI/Metadata') diff --git a/src/SMAPI/Metadata/CoreAssetPropagator.cs b/src/SMAPI/Metadata/CoreAssetPropagator.cs index bd1cc50e..72130e05 100644 --- a/src/SMAPI/Metadata/CoreAssetPropagator.cs +++ b/src/SMAPI/Metadata/CoreAssetPropagator.cs @@ -373,52 +373,6 @@ namespace StardewModdingAPI.Metadata case "loosesprites\\suspensionbridge": // SuspensionBridge constructor return this.ReloadSuspensionBridges(content, key); - /**** - ** Content\TileSheets - ****/ - case "tilesheets\\chairtiles": // Game1.LoadContent - MapSeat.mapChairTexture = content.Load(key); - return true; - - case "tilesheets\\critters": // Critter constructor - return this.ReloadCritterTextures(content, key) > 0; - - case "tilesheets\\crops": // Game1.LoadContent - Game1.cropSpriteSheet = content.Load(key); - return true; - - case "tilesheets\\debris": // Game1.LoadContent - Game1.debrisSpriteSheet = content.Load(key); - return true; - - case "tilesheets\\emotes": // Game1.LoadContent - Game1.emoteSpriteSheet = content.Load(key); - return true; - - case "tilesheets\\furniture": // Game1.LoadContent - Furniture.furnitureTexture = content.Load(key); - return true; - - case "tilesheets\\furniturefront": // Game1.LoadContent - Furniture.furnitureFrontTexture = content.Load(key); - return true; - - case "tilesheets\\projectiles": // Game1.LoadContent - Projectile.projectileSheet = content.Load(key); - return true; - - case "tilesheets\\rain": // Game1.LoadContent - Game1.rainTexture = content.Load(key); - return true; - - case "tilesheets\\tools": // Game1.ResetToolSpriteSheet - Game1.ResetToolSpriteSheet(); - return true; - - case "tilesheets\\weapons": // Game1.LoadContent - Tool.weaponsTexture = content.Load(key); - return true; - /**** ** Content\Maps ****/ @@ -469,14 +423,57 @@ namespace StardewModdingAPI.Metadata Bush.texture = new Lazy(() => content.Load(key)); return true; + case "tilesheets\\chairtiles": // Game1.LoadContent + MapSeat.mapChairTexture = content.Load(key); + return true; + case "tilesheets\\craftables": // Game1.LoadContent Game1.bigCraftableSpriteSheet = content.Load(key); return true; + case "tilesheets\\critters": // Critter constructor + return this.ReloadCritterTextures(content, key) > 0; + + case "tilesheets\\crops": // Game1.LoadContent + Game1.cropSpriteSheet = content.Load(key); + return true; + + case "tilesheets\\debris": // Game1.LoadContent + Game1.debrisSpriteSheet = content.Load(key); + return true; + + case "tilesheets\\emotes": // Game1.LoadContent + Game1.emoteSpriteSheet = content.Load(key); + return true; + case "tilesheets\\fruittrees": // FruitTree FruitTree.texture = content.Load(key); return true; + case "tilesheets\\furniture": // Game1.LoadContent + Furniture.furnitureTexture = content.Load(key); + return true; + + case "tilesheets\\furniturefront": // Game1.LoadContent + Furniture.furnitureFrontTexture = content.Load(key); + return true; + + case "tilesheets\\projectiles": // Game1.LoadContent + Projectile.projectileSheet = content.Load(key); + return true; + + case "tilesheets\\rain": // Game1.LoadContent + Game1.rainTexture = content.Load(key); + return true; + + case "tilesheets\\tools": // Game1.ResetToolSpriteSheet + Game1.ResetToolSpriteSheet(); + return true; + + case "tilesheets\\weapons": // Game1.LoadContent + Tool.weaponsTexture = content.Load(key); + return true; + /**** ** Content\TerrainFeatures ****/ @@ -528,6 +525,9 @@ namespace StardewModdingAPI.Metadata return this.ReloadTreeTextures(content, key, Tree.pineTree); } + /**** + ** Dynamic assets + ****/ // dynamic textures if (this.KeyStartsWith(key, "animals\\cat")) return this.ReloadPetOrHorseSprites(content, key); -- cgit From 9fb6d67417ee3f2db0754b135786e052ae308683 Mon Sep 17 00:00:00 2001 From: Jesse Plamondon-Willard Date: Mon, 18 Jan 2021 18:52:31 -0500 Subject: add asset propagation for Strings\StringsFromCSFiles --- docs/release-notes.md | 11 +++++++---- src/SMAPI/Metadata/CoreAssetPropagator.cs | 27 +++++++++++++++++++++++++++ 2 files changed, 34 insertions(+), 4 deletions(-) (limited to 'src/SMAPI/Metadata') diff --git a/docs/release-notes.md b/docs/release-notes.md index bb379898..9a63de7c 100644 --- a/docs/release-notes.md +++ b/docs/release-notes.md @@ -12,11 +12,14 @@ * Improved game path detection in the installer. The installer now prefers the path registered by Steam or GOG Galaxy, and can also now detect the default install path for manual GOG installs. * For modders: - * Expanded `PerScreen` API: you can now get/set the value for any screen, get all active values, or clear all values. - * Expanded player info received from multiplayer API/events with new `IsSplitScreen` and `ScreenID` fields. + * Improved multiplayer APIs: + * `PerScreen` now lets you get/set the value for any screen, get all active values, or clear all values. + * Peer data for the multiplayer API/events now includes `IsSplitScreen` and `ScreenID` fields. + * Network messages through the multiplayer API are no longer sent to players who don't have SMAPI installed. This reduces unneeded network traffic (since they can't read it anyway) and avoids an error in some cases. + * Improved asset propagation: + * Added propagation for some `Strings\StringsFromCSFiles` keys (mainly short day names). + * Added an option to disable rewriting mods for compatibility (thanks to Bpendragon!). This prevents older mods from loading but bypasses a Visual Studio debugger crash. * Game errors shown in the chatbox are now logged. - * Added an option to disable rewriting mods for compatibility (thanks to Bpendragon!). This may prevent older mods from loading, but bypasses a Visual Studio crash when debugging. - * Network messages through the multiplayer API are no longer sent to players who don't have SMAPI installed. This reduces unneeded network traffic (since they can't read it anyway) and avoids an error in some cases. * For the Error Handler mod: * Added in SMAPI 3.9. This has vanilla error-handling that was previously added by SMAPI directly. That simplifies the core SMAPI logic, and lets players or modders disable it if needed. diff --git a/src/SMAPI/Metadata/CoreAssetPropagator.cs b/src/SMAPI/Metadata/CoreAssetPropagator.cs index 72130e05..24b578ad 100644 --- a/src/SMAPI/Metadata/CoreAssetPropagator.cs +++ b/src/SMAPI/Metadata/CoreAssetPropagator.cs @@ -408,6 +408,12 @@ namespace StardewModdingAPI.Metadata case "minigames\\titlebuttons": // TitleMenu return this.ReloadTitleButtons(content, key); + /**** + ** Content\Strings + ****/ + case "strings\\stringsfromcsfiles": + return this.ReloadStringsFromCsFiles(content); + /**** ** Content\TileSheets ****/ @@ -1028,6 +1034,27 @@ namespace StardewModdingAPI.Metadata return true; } + /// Reload cached translations from the Strings\StringsFromCSFiles asset. + /// The content manager through which to reload the asset. + /// Returns whether any data was reloaded. + /// Derived from the . + private bool ReloadStringsFromCsFiles(LocalizedContentManager content) + { + Game1.samBandName = content.LoadString("Strings\\StringsFromCSFiles:Game1.cs.2156"); + Game1.elliottBookName = content.LoadString("Strings\\StringsFromCSFiles:Game1.cs.2157"); + + string[] dayNames = this.Reflection.GetField(typeof(Game1), "_shortDayDisplayName").GetValue(); + dayNames[0] = content.LoadString("Strings\\StringsFromCSFiles:Game1.cs.3042"); + dayNames[1] = content.LoadString("Strings\\StringsFromCSFiles:Game1.cs.3043"); + dayNames[2] = content.LoadString("Strings\\StringsFromCSFiles:Game1.cs.3044"); + dayNames[3] = content.LoadString("Strings\\StringsFromCSFiles:Game1.cs.3045"); + dayNames[4] = content.LoadString("Strings\\StringsFromCSFiles:Game1.cs.3046"); + dayNames[5] = content.LoadString("Strings\\StringsFromCSFiles:Game1.cs.3047"); + dayNames[6] = content.LoadString("Strings\\StringsFromCSFiles:Game1.cs.3048"); + + return true; + } + /**** ** Helpers ****/ -- cgit From 00e545715d89f32ab999a3b1f6ae70edec158591 Mon Sep 17 00:00:00 2001 From: Jesse Plamondon-Willard Date: Mon, 18 Jan 2021 23:19:34 -0500 Subject: reset map overrides when reloading a map (#751) --- docs/release-notes.md | 1 + src/SMAPI/Metadata/CoreAssetPropagator.cs | 1 + 2 files changed, 2 insertions(+) (limited to 'src/SMAPI/Metadata') diff --git a/docs/release-notes.md b/docs/release-notes.md index 9a63de7c..bc50b197 100644 --- a/docs/release-notes.md +++ b/docs/release-notes.md @@ -18,6 +18,7 @@ * Network messages through the multiplayer API are no longer sent to players who don't have SMAPI installed. This reduces unneeded network traffic (since they can't read it anyway) and avoids an error in some cases. * Improved asset propagation: * Added propagation for some `Strings\StringsFromCSFiles` keys (mainly short day names). + * Fixed some town patches not reapplied when the map is reloaded in Stardew Valley 1.5. * Added an option to disable rewriting mods for compatibility (thanks to Bpendragon!). This prevents older mods from loading but bypasses a Visual Studio debugger crash. * Game errors shown in the chatbox are now logged. diff --git a/src/SMAPI/Metadata/CoreAssetPropagator.cs b/src/SMAPI/Metadata/CoreAssetPropagator.cs index 24b578ad..29c4dc1d 100644 --- a/src/SMAPI/Metadata/CoreAssetPropagator.cs +++ b/src/SMAPI/Metadata/CoreAssetPropagator.cs @@ -785,6 +785,7 @@ namespace StardewModdingAPI.Metadata private void ReloadMap(GameLocation location) { // reset patch caches + this.Reflection.GetField>(location, "_appliedMapOverrides").GetValue().Clear(); switch (location) { case Town _: -- cgit From 5676d94fe655c42e50c27b5eae72b9c96cfc2476 Mon Sep 17 00:00:00 2001 From: Jesse Plamondon-Willard Date: Tue, 19 Jan 2021 01:05:15 -0500 Subject: reset some missed map cache fields (#751) --- docs/release-notes.md | 3 ++- src/SMAPI/Metadata/CoreAssetPropagator.cs | 5 +++++ 2 files changed, 7 insertions(+), 1 deletion(-) (limited to 'src/SMAPI/Metadata') diff --git a/docs/release-notes.md b/docs/release-notes.md index bc50b197..8e31b79c 100644 --- a/docs/release-notes.md +++ b/docs/release-notes.md @@ -18,7 +18,8 @@ * Network messages through the multiplayer API are no longer sent to players who don't have SMAPI installed. This reduces unneeded network traffic (since they can't read it anyway) and avoids an error in some cases. * Improved asset propagation: * Added propagation for some `Strings\StringsFromCSFiles` keys (mainly short day names). - * Fixed some town patches not reapplied when the map is reloaded in Stardew Valley 1.5. + * Fixed some of the game's map changes not reapplied after reloading a map in Stardew Valley 1.5. + * Fixed quarry bridge not fixed if the mountain map was reloaded. * Added an option to disable rewriting mods for compatibility (thanks to Bpendragon!). This prevents older mods from loading but bypasses a Visual Studio debugger crash. * Game errors shown in the chatbox are now logged. diff --git a/src/SMAPI/Metadata/CoreAssetPropagator.cs b/src/SMAPI/Metadata/CoreAssetPropagator.cs index 29c4dc1d..859a1b7a 100644 --- a/src/SMAPI/Metadata/CoreAssetPropagator.cs +++ b/src/SMAPI/Metadata/CoreAssetPropagator.cs @@ -791,6 +791,7 @@ namespace StardewModdingAPI.Metadata case Town _: this.Reflection.GetField(location, "ccRefurbished").SetValue(false); this.Reflection.GetField(location, "isShowingDestroyedJoja").SetValue(false); + this.Reflection.GetField(location, "isShowingSpecialOrdersBoard").SetValue(false); this.Reflection.GetField(location, "isShowingUpgradedPamHouse").SetValue(false); break; @@ -799,6 +800,10 @@ namespace StardewModdingAPI.Metadata case Forest _: this.Reflection.GetField(location, "hasShownCCUpgrade").SetValue(false); break; + + case Mountain _: + this.Reflection.GetField(location, "bridgeRestored").SetValue(false); + break; } // general updates -- cgit From 8fd2a6fd3a3de037055ccd8ec350c92ba2cdda9d Mon Sep 17 00:00:00 2001 From: Jesse Plamondon-Willard Date: Fri, 22 Jan 2021 20:17:01 -0500 Subject: update for new map override logic in SDV 1.5.4 Special thanks to the Stardew Valley developers for making the requested changes! --- docs/release-notes.md | 4 +++- src/SMAPI/Constants.cs | 2 +- src/SMAPI/Metadata/CoreAssetPropagator.cs | 26 ++------------------------ 3 files changed, 6 insertions(+), 26 deletions(-) (limited to 'src/SMAPI/Metadata') diff --git a/docs/release-notes.md b/docs/release-notes.md index 58bc2826..0d5fdea4 100644 --- a/docs/release-notes.md +++ b/docs/release-notes.md @@ -9,10 +9,12 @@ ## Upcoming release * For players: + * Updated for Stardew Valley 1.5.4. * Improved game detection in the installer: * The installer now prefers paths registered by Steam or GOG Galaxy. * The installer now detects default manual GOG installs. * Added clearer error when Vortex creates an empty mod folder. + * Fixed various cases where the game's map changes wouldn't be reapplied correctly after mods changed the map. * Fixed compatibility for very old content packs which still load maps from `.xnb` files. These were broken by map loading changes in Stardew Valley 1.5, but SMAPI now corrects them automatically. * Fixed some broken mods incorrectly listed as XNB mods under 'skipped mods'. @@ -28,7 +30,7 @@ * Network messages through the multiplayer API are no longer sent to players who don't have SMAPI installed. This reduces unneeded network traffic (since they can't read it anyway) and avoids an error in some cases. * Improved asset propagation: * Added propagation for some `Strings\StringsFromCSFiles` keys (mainly short day names). - * Fixed some of the game's map changes not reapplied after reloading a map in Stardew Valley 1.5. + * Updated map propagation for the changes in Stardew Valley 1.5.4. * Fixed quarry bridge not fixed if the mountain map was reloaded. * Added an option to disable rewriting mods for compatibility (thanks to Bpendragon!). This prevents older mods from loading but bypasses a Visual Studio debugger crash. * Game errors shown in the chatbox are now logged. diff --git a/src/SMAPI/Constants.cs b/src/SMAPI/Constants.cs index b72471ca..36745ea7 100644 --- a/src/SMAPI/Constants.cs +++ b/src/SMAPI/Constants.cs @@ -57,7 +57,7 @@ namespace StardewModdingAPI public static ISemanticVersion ApiVersion { get; } = new Toolkit.SemanticVersion("3.8.4"); /// The minimum supported version of Stardew Valley. - public static ISemanticVersion MinimumGameVersion { get; } = new GameVersion("1.5.3"); + public static ISemanticVersion MinimumGameVersion { get; } = new GameVersion("1.5.4"); /// The maximum supported version of Stardew Valley. public static ISemanticVersion MaximumGameVersion { get; } = null; diff --git a/src/SMAPI/Metadata/CoreAssetPropagator.cs b/src/SMAPI/Metadata/CoreAssetPropagator.cs index 859a1b7a..4b911a83 100644 --- a/src/SMAPI/Metadata/CoreAssetPropagator.cs +++ b/src/SMAPI/Metadata/CoreAssetPropagator.cs @@ -784,32 +784,10 @@ namespace StardewModdingAPI.Metadata /// The location whose map to reload. private void ReloadMap(GameLocation location) { - // reset patch caches - this.Reflection.GetField>(location, "_appliedMapOverrides").GetValue().Clear(); - switch (location) - { - case Town _: - this.Reflection.GetField(location, "ccRefurbished").SetValue(false); - this.Reflection.GetField(location, "isShowingDestroyedJoja").SetValue(false); - this.Reflection.GetField(location, "isShowingSpecialOrdersBoard").SetValue(false); - this.Reflection.GetField(location, "isShowingUpgradedPamHouse").SetValue(false); - break; - - case Beach _: - case BeachNightMarket _: - case Forest _: - this.Reflection.GetField(location, "hasShownCCUpgrade").SetValue(false); - break; - - case Mountain _: - this.Reflection.GetField(location, "bridgeRestored").SetValue(false); - break; - } - - // general updates + // reload map location.reloadMap(); - location.updateSeasonalTileSheets(); location.updateWarps(); + location.MakeMapModifications(force: true); // update interior doors location.interiorDoors.Clear(); -- cgit