From 3fa0433c9862d1922cd0540848d2bd8716934d1f Mon Sep 17 00:00:00 2001 From: Jesse Plamondon-Willard Date: Fri, 2 Apr 2021 21:30:55 -0400 Subject: add initial support for 64-bit Windows hack (#767) --- src/SMAPI.Mods.ErrorHandler/SMAPI.Mods.ErrorHandler.csproj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/SMAPI.Mods.ErrorHandler') diff --git a/src/SMAPI.Mods.ErrorHandler/SMAPI.Mods.ErrorHandler.csproj b/src/SMAPI.Mods.ErrorHandler/SMAPI.Mods.ErrorHandler.csproj index 788f6f16..56daa710 100644 --- a/src/SMAPI.Mods.ErrorHandler/SMAPI.Mods.ErrorHandler.csproj +++ b/src/SMAPI.Mods.ErrorHandler/SMAPI.Mods.ErrorHandler.csproj @@ -19,7 +19,7 @@ - + -- cgit From 28c5cb79d4ca671881c54f473a9cfb6235298099 Mon Sep 17 00:00:00 2001 From: Jesse Plamondon-Willard Date: Sat, 1 May 2021 17:39:34 -0400 Subject: add error-handling for seasonal tilesheet crash --- docs/release-notes.md | 3 +- .../Patches/GameLocationPatches.cs | 59 ++++++++++++++++++++-- .../SMAPI.Mods.ErrorHandler.csproj | 1 + 3 files changed, 58 insertions(+), 5 deletions(-) (limited to 'src/SMAPI.Mods.ErrorHandler') diff --git a/docs/release-notes.md b/docs/release-notes.md index 701471ee..8b81264a 100644 --- a/docs/release-notes.md +++ b/docs/release-notes.md @@ -11,7 +11,8 @@ * For players: * Added support for unofficial 64-bit Stardew Valley, including automatic support in the SMAPI installer. * Added update checks for Stardew64Installer if it patched the game. - * When many mods fail to load, root dependencies are now listed in their own group so it's easier to see which ones you should try updating first. + * Added smarter grouping for skipped mods, so it's easier to see root dependencies to update first. + * Added error-handling to prevent a crash when the game can't update a map's seasonal tilesheets _(in Error Handler)_. * On macOS, the `StardewModdingAPI.bin.osx` file is no longer overwritten if it's identical to avoid resetting file permissions (thanks to 007wayne!). * `*.ico` files are now ignored when scanning for mods. * Fixed error for non-English players after returning to title, reloading, and entering town with a completed movie theater. diff --git a/src/SMAPI.Mods.ErrorHandler/Patches/GameLocationPatches.cs b/src/SMAPI.Mods.ErrorHandler/Patches/GameLocationPatches.cs index 1edf2d6a..7a48133e 100644 --- a/src/SMAPI.Mods.ErrorHandler/Patches/GameLocationPatches.cs +++ b/src/SMAPI.Mods.ErrorHandler/Patches/GameLocationPatches.cs @@ -8,10 +8,11 @@ using Harmony; #endif using StardewModdingAPI.Framework.Patching; using StardewValley; +using xTile; namespace StardewModdingAPI.Mods.ErrorHandler.Patches { - /// A Harmony patch for which intercepts invalid preconditions and logs an error instead of crashing. + /// Harmony patches for and which intercept errors instead of crashing. /// Patch methods must be static for Harmony to work correctly. See the Harmony documentation before renaming patch arguments. [SuppressMessage("ReSharper", "InconsistentNaming", Justification = "Argument names are defined by Harmony and methods are named for clarity.")] [SuppressMessage("ReSharper", "IdentifierTypo", Justification = "Argument names are defined by Harmony and methods are named for clarity.")] @@ -39,17 +40,25 @@ namespace StardewModdingAPI.Mods.ErrorHandler.Patches public void Apply(Harmony harmony) { harmony.Patch( - original: AccessTools.Method(typeof(GameLocation), "checkEventPrecondition"), + original: AccessTools.Method(typeof(GameLocation), nameof(GameLocation.checkEventPrecondition)), finalizer: new HarmonyMethod(this.GetType(), nameof(EventErrorPatch.Finalize_GameLocation_CheckEventPrecondition)) ); +harmony.Patch( + original: AccessTools.Method(typeof(GameLocation), nameof(GameLocation.updateSeasonalTileSheets)), + finalizer: new HarmonyMethod(this.GetType(), nameof(EventErrorPatch.Before_GameLocation_UpdateSeasonalTileSheets)) + ); } #else public void Apply(HarmonyInstance harmony) { harmony.Patch( - original: AccessTools.Method(typeof(GameLocation), "checkEventPrecondition"), + original: AccessTools.Method(typeof(GameLocation), nameof(GameLocation.checkEventPrecondition)), prefix: new HarmonyMethod(this.GetType(), nameof(GameLocationPatches.Before_GameLocation_CheckEventPrecondition)) ); + harmony.Patch( + original: AccessTools.Method(typeof(GameLocation), nameof(GameLocation.updateSeasonalTileSheets)), + prefix: new HarmonyMethod(this.GetType(), nameof(GameLocationPatches.Before_GameLocation_UpdateSeasonalTileSheets)) + ); } #endif @@ -74,7 +83,7 @@ namespace StardewModdingAPI.Mods.ErrorHandler.Patches return null; } #else - /// The method to call instead of GameLocation.checkEventPrecondition. + /// The method to call instead of . /// The instance being patched. /// The return value of the original method. /// The precondition to be parsed. @@ -103,5 +112,47 @@ namespace StardewModdingAPI.Mods.ErrorHandler.Patches } } #endif + +#if HARMONY_2 + /// The method to call instead of . + /// The instance being patched. + /// The map whose tilesheets to update. + /// The exception thrown by the wrapped method, if any. + /// Returns the exception to throw, if any. + private static Exception Before_GameLocation_UpdateSeasonalTileSheets(GameLocation __instance, Map map, Exception __exception) + { + if (__exception != null) + GameLocationPatches.MonitorForGame.Log($"Failed updating seasonal tilesheets for location '{__instance.NameOrUniqueName}': \n{__exception}", LogLevel.Error); + + return null; + } +#else + /// The method to call instead of . + /// The instance being patched. + /// The map whose tilesheets to update. + /// The method being wrapped. + /// Returns whether to execute the original method. + private static bool Before_GameLocation_UpdateSeasonalTileSheets(GameLocation __instance, Map map, MethodInfo __originalMethod) + { + const string key = nameof(GameLocationPatches.Before_GameLocation_UpdateSeasonalTileSheets); + if (!PatchHelper.StartIntercept(key)) + return true; + + try + { + __originalMethod.Invoke(__instance, new object[] { map }); + return false; + } + catch (TargetInvocationException ex) + { + GameLocationPatches.MonitorForGame.Log($"Failed updating seasonal tilesheets for location '{__instance.NameOrUniqueName}'. Technical details:\n{ex.InnerException}", LogLevel.Error); + return false; + } + finally + { + PatchHelper.StopIntercept(key); + } + } +#endif } } diff --git a/src/SMAPI.Mods.ErrorHandler/SMAPI.Mods.ErrorHandler.csproj b/src/SMAPI.Mods.ErrorHandler/SMAPI.Mods.ErrorHandler.csproj index 56daa710..006a09ca 100644 --- a/src/SMAPI.Mods.ErrorHandler/SMAPI.Mods.ErrorHandler.csproj +++ b/src/SMAPI.Mods.ErrorHandler/SMAPI.Mods.ErrorHandler.csproj @@ -15,6 +15,7 @@ + -- cgit From 3447e2f575c2c83af729777e4d37e93f4c2a6467 Mon Sep 17 00:00:00 2001 From: Jesse Plamondon-Willard Date: Mon, 3 May 2021 18:11:06 -0400 Subject: prepare for release --- build/common.targets | 2 +- docs/release-notes.md | 15 +++++++-------- src/SMAPI.Mods.ConsoleCommands/manifest.json | 4 ++-- src/SMAPI.Mods.ErrorHandler/manifest.json | 4 ++-- src/SMAPI.Mods.SaveBackup/manifest.json | 4 ++-- src/SMAPI/Constants.cs | 2 +- 6 files changed, 15 insertions(+), 16 deletions(-) (limited to 'src/SMAPI.Mods.ErrorHandler') diff --git a/build/common.targets b/build/common.targets index 6834c162..3278a0da 100644 --- a/build/common.targets +++ b/build/common.targets @@ -1,7 +1,7 @@ - 3.9.5 + 3.10.0 SMAPI latest $(AssemblySearchPaths);{GAC} diff --git a/docs/release-notes.md b/docs/release-notes.md index 27786e18..b697cd2b 100644 --- a/docs/release-notes.md +++ b/docs/release-notes.md @@ -7,30 +7,29 @@ * Migrated to Harmony 2.0 (see [_migrate to Harmony 2.0_](https://stardewvalleywiki.com/Modding:Migrate_to_Harmony_2.0) for more info). --> -## Upcoming release +## 3.10 +Released 03 May 2021 for Stardew Valley 1.5.4 or later. See [release highlights](https://www.patreon.com/posts/50764911). + * For players: - * Added support for unofficial 64-bit Stardew Valley, including automatic support in the SMAPI installer. - * Added update checks for Stardew64Installer if it patched the game. + * Added full support for the [unofficial 64-bit Stardew Valley patch](https://stardewvalleywiki.com/Modding:Migrate_to_64-bit_on_Windows), which removes memory limits. The installer detects which version of SMAPI you need, and SMAPI shows update alerts for Stardew64Installer if applicable. * Added smarter grouping for skipped mods, so it's easier to see root dependencies to update first. - * Added error-handling to prevent a crash when the game can't update a map's seasonal tilesheets _(in Error Handler)_. + * Added crash recovery when the game can't update a map's seasonal tilesheets _(in Error Handler)_. SMAPI will log an error and keep the previous tilesheets in that case. * Added installer option to enter a custom game path even if it detected a game folder. * `*.ico` files are now ignored when scanning for mods. - * Fixed `StardewModdingAPI.bin.osx` on macOS overwritten with an identical file on launch, which resets file permissions (thanks to 007wayne!). * Fixed error for non-English players after returning to title, reloading, and entering town with a completed movie theater. * Fixed `world_clear` console command not removing resource clumps outside the farm and secret woods. * Fixed error running SMAPI in a strict sandbox on Linux (thanks to kuesji!). + * Fixed `StardewModdingAPI.bin.osx` on macOS overwritten with an identical file on launch which would reset file permissions (thanks to 007wayne!). * Fixed inconsistent spelling/style for 'macOS'. * For modders: + * Added support for [ignoring local map tilesheet files when loading a map](https://stardewvalleywiki.com/Modding:Maps#Local_copy_of_a_vanilla_tilesheet). * Added asset propagation for `Data\Concessions`. * Added SMAPI version and bitness to the console title before startup to simplify troubleshooting. - * Added support for [ignoring local map tilesheet files when loading a map](https://stardewvalleywiki.com/Modding:Maps#Local_copy_of_a_vanilla_tilesheet). * If a map loads a tilesheet path with no file extension, SMAPI now automatically links it to a `.png` version in the map folder if possible. * Improved error-handling during asset propagation. * Fixed `Context.IsMainPlayer` returning true for a farmhand in split-screen mode before the screen is initialized. * Fixed error when editing bundle data while a split-screen player is joining. - -* For the web API: * Fixed update subkeys not working in file descriptions for Nexus mods marked as adult content. ## 3.9.5 diff --git a/src/SMAPI.Mods.ConsoleCommands/manifest.json b/src/SMAPI.Mods.ConsoleCommands/manifest.json index 65c66d33..10e6733f 100644 --- a/src/SMAPI.Mods.ConsoleCommands/manifest.json +++ b/src/SMAPI.Mods.ConsoleCommands/manifest.json @@ -1,9 +1,9 @@ { "Name": "Console Commands", "Author": "SMAPI", - "Version": "3.9.5", + "Version": "3.10.0", "Description": "Adds SMAPI console commands that let you manipulate the game.", "UniqueID": "SMAPI.ConsoleCommands", "EntryDll": "ConsoleCommands.dll", - "MinimumApiVersion": "3.9.5" + "MinimumApiVersion": "3.10.0" } diff --git a/src/SMAPI.Mods.ErrorHandler/manifest.json b/src/SMAPI.Mods.ErrorHandler/manifest.json index 1e810113..ab519781 100644 --- a/src/SMAPI.Mods.ErrorHandler/manifest.json +++ b/src/SMAPI.Mods.ErrorHandler/manifest.json @@ -1,9 +1,9 @@ { "Name": "Error Handler", "Author": "SMAPI", - "Version": "3.9.5", + "Version": "3.10.0", "Description": "Handles some common vanilla errors to log more useful info or avoid breaking the game.", "UniqueID": "SMAPI.ErrorHandler", "EntryDll": "ErrorHandler.dll", - "MinimumApiVersion": "3.9.5" + "MinimumApiVersion": "3.10.0" } diff --git a/src/SMAPI.Mods.SaveBackup/manifest.json b/src/SMAPI.Mods.SaveBackup/manifest.json index ced7888a..0d421b8f 100644 --- a/src/SMAPI.Mods.SaveBackup/manifest.json +++ b/src/SMAPI.Mods.SaveBackup/manifest.json @@ -1,9 +1,9 @@ { "Name": "Save Backup", "Author": "SMAPI", - "Version": "3.9.5", + "Version": "3.10.0", "Description": "Automatically backs up all your saves once per day into its folder.", "UniqueID": "SMAPI.SaveBackup", "EntryDll": "SaveBackup.dll", - "MinimumApiVersion": "3.9.5" + "MinimumApiVersion": "3.10.0" } diff --git a/src/SMAPI/Constants.cs b/src/SMAPI/Constants.cs index 161e92b4..3c21b205 100644 --- a/src/SMAPI/Constants.cs +++ b/src/SMAPI/Constants.cs @@ -61,7 +61,7 @@ namespace StardewModdingAPI internal static int? LogScreenId { get; set; } /// SMAPI's current raw semantic version. - internal static string RawApiVersion = "3.9.5"; + internal static string RawApiVersion = "3.10.0"; } /// Contains SMAPI's constants and assumptions. -- cgit