From 86607423916785ae7d0933436d8a755581f35b2b Mon Sep 17 00:00:00 2001 From: DaLion Date: Wed, 7 Dec 2022 18:13:17 -0300 Subject: Replaced slingshot ID check with Type check. --- src/SMAPI.Mods.ConsoleCommands/Framework/ItemRepository.cs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/SMAPI.Mods.ConsoleCommands/Framework/ItemRepository.cs b/src/SMAPI.Mods.ConsoleCommands/Framework/ItemRepository.cs index 88ddfe6b..99de01b9 100644 --- a/src/SMAPI.Mods.ConsoleCommands/Framework/ItemRepository.cs +++ b/src/SMAPI.Mods.ConsoleCommands/Framework/ItemRepository.cs @@ -104,9 +104,10 @@ namespace StardewModdingAPI.Mods.ConsoleCommands.Framework // weapons if (ShouldGet(ItemType.Weapon)) { - foreach (int id in this.TryLoad("Data\\weapons").Keys) + var weaponsData = this.TryLoad("Data\\weapons"); + foreach (int id in weaponsData.Keys) { - yield return this.TryCreate(ItemType.Weapon, id, p => p.ID is >= 32 and <= 34 + yield return this.TryCreate(ItemType.Weapon, id, p => weaponsData[p.ID].Split('/')[8] == "4" ? new Slingshot(p.ID) : new MeleeWeapon(p.ID) ); -- cgit From 45979c57dd350fc5c08155fd0794cf3c3519a256 Mon Sep 17 00:00:00 2001 From: Jesse Plamondon-Willard Date: Wed, 28 Dec 2022 11:30:35 -0500 Subject: defer weapon data parsing until needed, handle invalid formats --- .../Framework/ItemRepository.cs | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/src/SMAPI.Mods.ConsoleCommands/Framework/ItemRepository.cs b/src/SMAPI.Mods.ConsoleCommands/Framework/ItemRepository.cs index 99de01b9..c4619577 100644 --- a/src/SMAPI.Mods.ConsoleCommands/Framework/ItemRepository.cs +++ b/src/SMAPI.Mods.ConsoleCommands/Framework/ItemRepository.cs @@ -104,13 +104,18 @@ namespace StardewModdingAPI.Mods.ConsoleCommands.Framework // weapons if (ShouldGet(ItemType.Weapon)) { - var weaponsData = this.TryLoad("Data\\weapons"); - foreach (int id in weaponsData.Keys) + Dictionary weaponsData = this.TryLoad("Data\\weapons"); + foreach (KeyValuePair pair in weaponsData) { - yield return this.TryCreate(ItemType.Weapon, id, p => weaponsData[p.ID].Split('/')[8] == "4" - ? new Slingshot(p.ID) - : new MeleeWeapon(p.ID) - ); + string rawFields = pair.Value; + yield return this.TryCreate(ItemType.Weapon, pair.Key, p => + { + string[] fields = rawFields.Split('/'); + bool isSlingshot = fields.Length > 8 && fields[8] == "4"; + return isSlingshot + ? new Slingshot(p.ID) + : new MeleeWeapon(p.ID); + }); } } -- cgit From 81d3baa3b516a41c4be79e833516f890b92e3dbb Mon Sep 17 00:00:00 2001 From: Jesse Plamondon-Willard Date: Wed, 28 Dec 2022 11:35:05 -0500 Subject: simplify Save Backup compression We don't need special handling for macOS anymore, since all platforms have .NET 5 now. --- docs/release-notes.md | 4 +++ src/SMAPI.Mods.SaveBackup/ModEntry.cs | 57 +++-------------------------------- 2 files changed, 9 insertions(+), 52 deletions(-) diff --git a/docs/release-notes.md b/docs/release-notes.md index ae98a0c4..54cbf96c 100644 --- a/docs/release-notes.md +++ b/docs/release-notes.md @@ -7,6 +7,10 @@ _If needed, you can update to SMAPI 3.16.0 first and then install the latest version._ --> +## Upcoming release +* For players: + * Fixed save backups being empty in rare cases on macOS. + ## 3.18.1 Released 01 December 2022 for Stardew Valley 1.5.6 or later. diff --git a/src/SMAPI.Mods.SaveBackup/ModEntry.cs b/src/SMAPI.Mods.SaveBackup/ModEntry.cs index a79c092f..8a22a5f3 100644 --- a/src/SMAPI.Mods.SaveBackup/ModEntry.cs +++ b/src/SMAPI.Mods.SaveBackup/ModEntry.cs @@ -1,10 +1,8 @@ using System; -using System.Diagnostics; using System.Diagnostics.CodeAnalysis; using System.IO; using System.IO.Compression; using System.Linq; -using System.Reflection; using System.Threading.Tasks; using StardewValley; @@ -81,7 +79,7 @@ namespace StardewModdingAPI.Mods.SaveBackup } // compress backup if possible - if (!this.TryCompress(fallbackDir.FullName, targetFile, out Exception? compressError)) + if (!this.TryCompressDir(fallbackDir.FullName, targetFile, out Exception? compressError)) { this.Monitor.Log(Constants.TargetPlatform != GamePlatform.Android ? $"Backed up to {fallbackDir.FullName}." // expected to fail on Android @@ -136,19 +134,16 @@ namespace StardewModdingAPI.Mods.SaveBackup } } - /// Create a zip using the best available method. - /// The file or directory path to zip. + /// Try to create a compressed zip file for a directory. + /// The directory path to zip. /// The destination file to create. /// The error which occurred trying to compress, if applicable. This is if compression isn't supported on this platform. /// Returns whether compression succeeded. - private bool TryCompress(string sourcePath, FileInfo destination, [NotNullWhen(false)] out Exception? error) + private bool TryCompressDir(string sourcePath, FileInfo destination, [NotNullWhen(false)] out Exception? error) { try { - if (Constants.TargetPlatform == GamePlatform.Mac) - this.CompressUsingMacProcess(sourcePath, destination); // due to limitations with the bundled Mono on macOS, we can't reference System.IO.Compression - else - this.CompressUsingNetFramework(sourcePath, destination); + ZipFile.CreateFromDirectory(sourcePath, destination.FullName, CompressionLevel.Fastest, false); error = null; return true; @@ -160,48 +155,6 @@ namespace StardewModdingAPI.Mods.SaveBackup } } - /// Create a zip using the .NET compression library. - /// The file or directory path to zip. - /// The destination file to create. - /// The compression libraries aren't available on this system. - private void CompressUsingNetFramework(string sourcePath, FileInfo destination) - { - // get compress method - MethodInfo createFromDirectory; - try - { - // create compressed backup - Assembly coreAssembly = Assembly.Load("System.IO.Compression, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"); - Assembly fsAssembly = Assembly.Load("System.IO.Compression.FileSystem, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"); - Type compressionLevelType = coreAssembly.GetType("System.IO.Compression.CompressionLevel") ?? throw new InvalidOperationException("Can't load CompressionLevel type."); - Type zipFileType = fsAssembly.GetType("System.IO.Compression.ZipFile") ?? throw new InvalidOperationException("Can't load ZipFile type."); - createFromDirectory = zipFileType.GetMethod("CreateFromDirectory", new[] { typeof(string), typeof(string), compressionLevelType, typeof(bool) }) ?? throw new InvalidOperationException("Can't load ZipFile.CreateFromDirectory method."); - } - catch (Exception ex) - { - throw new NotSupportedException("Couldn't load the .NET compression libraries on this system.", ex); - } - - // compress file - createFromDirectory.Invoke(null, new object[] { sourcePath, destination.FullName, CompressionLevel.Fastest, false }); - } - - /// Create a zip using a process command on macOS. - /// The file or directory path to zip. - /// The destination file to create. - private void CompressUsingMacProcess(string sourcePath, FileInfo destination) - { - DirectoryInfo saveFolder = new(sourcePath); - ProcessStartInfo startInfo = new() - { - FileName = "zip", - Arguments = $"-rq \"{destination.FullName}\" \"{saveFolder.Name}\" -x \"*.DS_Store\" -x \"__MACOSX\"", - WorkingDirectory = $"{saveFolder.FullName}/../", - CreateNoWindow = true - }; - new Process { StartInfo = startInfo }.Start(); - } - /// Recursively copy a directory or file. /// The file or folder to copy. /// The folder to copy into. -- cgit From d35f45fc3242d330a2021017054e932eff64f2ca Mon Sep 17 00:00:00 2001 From: Jesse Plamondon-Willard Date: Sat, 7 Jan 2023 17:55:15 -0500 Subject: fix game assemblies not excluded from release zip when bundle type not set --- docs/technical/mod-package.md | 1 + .../Framework/ModFileManager.cs | 23 ++++++++++++++++------ 2 files changed, 18 insertions(+), 6 deletions(-) diff --git a/docs/technical/mod-package.md b/docs/technical/mod-package.md index 707b1641..0e710e50 100644 --- a/docs/technical/mod-package.md +++ b/docs/technical/mod-package.md @@ -414,6 +414,7 @@ when you compile it. ## Release notes ## Upcoming release * Added `manifest.json` format validation on build (thanks to tylergibbs2!). +* Fixed game assemblies no longer excluded from the release zip if referenced explicitly without setting `BundleExtraAssemblies`. ### 4.0.2 Released 09 October 2022. diff --git a/src/SMAPI.ModBuildConfig/Framework/ModFileManager.cs b/src/SMAPI.ModBuildConfig/Framework/ModFileManager.cs index 00f3f439..d47e492a 100644 --- a/src/SMAPI.ModBuildConfig/Framework/ModFileManager.cs +++ b/src/SMAPI.ModBuildConfig/Framework/ModFileManager.cs @@ -215,13 +215,24 @@ namespace StardewModdingAPI.ModBuildConfig.Framework return true; } - // check for bundled assembly types - // When bundleAssemblyTypes is set, *all* dependencies are copied into the build output but only those which match the given assembly types should be bundled. - if (bundleAssemblyTypes != ExtraAssemblyTypes.None) + // ignore by assembly type + ExtraAssemblyTypes type = this.GetExtraAssemblyType(file, modDllName); + switch (bundleAssemblyTypes) { - var type = this.GetExtraAssemblyType(file, modDllName); - if (type != ExtraAssemblyTypes.None && !bundleAssemblyTypes.HasFlag(type)) - return true; + // Only explicitly-referenced assemblies are in the build output. These should be added to the zip, + // since it's possible the game won't load them (except game assemblies which will always be loaded + // separately). If they're already loaded, SMAPI will just ignore them. + case ExtraAssemblyTypes.None: + if (type is ExtraAssemblyTypes.Game) + return true; + break; + + // All assemblies are in the build output (due to how .NET builds references), but only those which + // match the bundled type should be in the zip. + default: + if (type != ExtraAssemblyTypes.None && !bundleAssemblyTypes.HasFlag(type)) + return true; + break; } return false; -- cgit From b246fe61452f15026382c7d6da687116fec546e1 Mon Sep 17 00:00:00 2001 From: Jesse Plamondon-Willard Date: Sun, 8 Jan 2023 16:43:23 -0500 Subject: update web to .NET 7 --- src/SMAPI.Web/SMAPI.Web.csproj | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/SMAPI.Web/SMAPI.Web.csproj b/src/SMAPI.Web/SMAPI.Web.csproj index 81b187fe..7d4013bd 100644 --- a/src/SMAPI.Web/SMAPI.Web.csproj +++ b/src/SMAPI.Web/SMAPI.Web.csproj @@ -2,7 +2,7 @@ SMAPI.Web StardewModdingAPI.Web - net6.0 + net7.0 latest @@ -22,7 +22,7 @@ - + -- cgit From 5518b8d461732796b0da5f4c9ba85be96bddc205 Mon Sep 17 00:00:00 2001 From: Jesse Plamondon-Willard Date: Sun, 8 Jan 2023 16:48:30 -0500 Subject: update packages --- docs/release-notes.md | 3 +++ .../SMAPI.ModBuildConfig.Analyzer.Tests.csproj | 4 ++-- src/SMAPI.ModBuildConfig/SMAPI.ModBuildConfig.csproj | 2 +- src/SMAPI.Tests/SMAPI.Tests.csproj | 10 +++++----- src/SMAPI.Toolkit/SMAPI.Toolkit.csproj | 4 ++-- src/SMAPI.Web/SMAPI.Web.csproj | 10 +++++----- src/SMAPI/SMAPI.csproj | 6 +++--- 7 files changed, 21 insertions(+), 18 deletions(-) diff --git a/docs/release-notes.md b/docs/release-notes.md index 54cbf96c..3731157b 100644 --- a/docs/release-notes.md +++ b/docs/release-notes.md @@ -11,6 +11,9 @@ * For players: * Fixed save backups being empty in rare cases on macOS. +* For mod authors: + * Updated to Newtonsoft.Json 13.0.2 (see [changes](https://github.com/JamesNK/Newtonsoft.Json/releases/tag/13.0.2)) and Pintail 2.2.1 (see [changes](https://github.com/Nanoray-pl/Pintail/blob/master/docs/release-notes.md#222)). + ## 3.18.1 Released 01 December 2022 for Stardew Valley 1.5.6 or later. diff --git a/src/SMAPI.ModBuildConfig.Analyzer.Tests/SMAPI.ModBuildConfig.Analyzer.Tests.csproj b/src/SMAPI.ModBuildConfig.Analyzer.Tests/SMAPI.ModBuildConfig.Analyzer.Tests.csproj index 3be9c225..1719d39b 100644 --- a/src/SMAPI.ModBuildConfig.Analyzer.Tests/SMAPI.ModBuildConfig.Analyzer.Tests.csproj +++ b/src/SMAPI.ModBuildConfig.Analyzer.Tests/SMAPI.ModBuildConfig.Analyzer.Tests.csproj @@ -6,9 +6,9 @@ - + - + diff --git a/src/SMAPI.ModBuildConfig/SMAPI.ModBuildConfig.csproj b/src/SMAPI.ModBuildConfig/SMAPI.ModBuildConfig.csproj index cded6f65..efc808a1 100644 --- a/src/SMAPI.ModBuildConfig/SMAPI.ModBuildConfig.csproj +++ b/src/SMAPI.ModBuildConfig/SMAPI.ModBuildConfig.csproj @@ -24,7 +24,7 @@ - + - 3.18.1 + 3.18.2 SMAPI latest $(AssemblySearchPaths);{GAC} diff --git a/docs/release-notes.md b/docs/release-notes.md index d095ce7c..9eb55b36 100644 --- a/docs/release-notes.md +++ b/docs/release-notes.md @@ -7,13 +7,16 @@ _If needed, you can update to SMAPI 3.16.0 first and then install the latest version._ --> -## Upcoming release +## 3.18.2 +Released 09 January 2023 for Stardew Valley 1.5.6 or later. + * For players: - * Fixed save backups being empty in rare cases on macOS. + * Fixed empty save backups for some macOS players. + * Fixed `player_add` console command not handling custom slingshots correctly (thanks too DaLion!). * For mod authors: - * Added `DelegatingModHooks` utility for rare cases where a mod needs to override SMAPI's mod hooks in the game directly. - * Updated to Newtonsoft.Json 13.0.2 (see [changes](https://github.com/JamesNK/Newtonsoft.Json/releases/tag/13.0.2)) and Pintail 2.2.1 (see [changes](https://github.com/Nanoray-pl/Pintail/blob/master/docs/release-notes.md#222)). + * Added `DelegatingModHooks` utility for mods which need to override SMAPI's mod hooks directly. + * Updated to Newtonsoft.Json 13.0.2 (see [changes](https://github.com/JamesNK/Newtonsoft.Json/releases/tag/13.0.2)) and Pintail 2.2.2 (see [changes](https://github.com/Nanoray-pl/Pintail/blob/master/docs/release-notes.md#222)). ## 3.18.1 Released 01 December 2022 for Stardew Valley 1.5.6 or later. diff --git a/docs/technical/mod-package.md b/docs/technical/mod-package.md index 0e710e50..23f0b221 100644 --- a/docs/technical/mod-package.md +++ b/docs/technical/mod-package.md @@ -412,9 +412,11 @@ The NuGet package is generated automatically in `StardewModdingAPI.ModBuildConfi when you compile it. ## Release notes -## Upcoming release +### 4.1.0 +Released 08 January 2023. + * Added `manifest.json` format validation on build (thanks to tylergibbs2!). -* Fixed game assemblies no longer excluded from the release zip if referenced explicitly without setting `BundleExtraAssemblies`. +* Fixed game DLLs not excluded from the release zip when they're referenced explicitly but `BundleExtraAssemblies` isn't set. ### 4.0.2 Released 09 October 2022. diff --git a/src/SMAPI.ModBuildConfig/SMAPI.ModBuildConfig.csproj b/src/SMAPI.ModBuildConfig/SMAPI.ModBuildConfig.csproj index efc808a1..badabfc7 100644 --- a/src/SMAPI.ModBuildConfig/SMAPI.ModBuildConfig.csproj +++ b/src/SMAPI.ModBuildConfig/SMAPI.ModBuildConfig.csproj @@ -10,7 +10,7 @@ Pathoschild.Stardew.ModBuildConfig Build package for SMAPI mods - 4.0.2 + 4.1.0 Pathoschild Automates the build configuration for crossplatform Stardew Valley SMAPI mods. For SMAPI 3.13.0 or later. MIT diff --git a/src/SMAPI.Mods.ConsoleCommands/manifest.json b/src/SMAPI.Mods.ConsoleCommands/manifest.json index 0afb5837..6ababef0 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.18.1", + "Version": "3.18.2", "Description": "Adds SMAPI console commands that let you manipulate the game.", "UniqueID": "SMAPI.ConsoleCommands", "EntryDll": "ConsoleCommands.dll", - "MinimumApiVersion": "3.18.1" + "MinimumApiVersion": "3.18.2" } diff --git a/src/SMAPI.Mods.ErrorHandler/manifest.json b/src/SMAPI.Mods.ErrorHandler/manifest.json index fe802d88..82630479 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.18.1", + "Version": "3.18.2", "Description": "Handles some common vanilla errors to log more useful info or avoid breaking the game.", "UniqueID": "SMAPI.ErrorHandler", "EntryDll": "ErrorHandler.dll", - "MinimumApiVersion": "3.18.1" + "MinimumApiVersion": "3.18.2" } diff --git a/src/SMAPI.Mods.SaveBackup/manifest.json b/src/SMAPI.Mods.SaveBackup/manifest.json index 9a587a2b..e29a3ed3 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.18.1", + "Version": "3.18.2", "Description": "Automatically backs up all your saves once per day into its folder.", "UniqueID": "SMAPI.SaveBackup", "EntryDll": "SaveBackup.dll", - "MinimumApiVersion": "3.18.1" + "MinimumApiVersion": "3.18.2" } diff --git a/src/SMAPI/Constants.cs b/src/SMAPI/Constants.cs index c5058e4b..482ec816 100644 --- a/src/SMAPI/Constants.cs +++ b/src/SMAPI/Constants.cs @@ -52,7 +52,7 @@ namespace StardewModdingAPI internal static int? LogScreenId { get; set; } /// SMAPI's current raw semantic version. - internal static string RawApiVersion = "3.18.1"; + internal static string RawApiVersion = "3.18.2"; } /// Contains SMAPI's constants and assumptions. -- cgit