From e8bb80af26997bc4e0ed43e4b2cc2cd5596e25f4 Mon Sep 17 00:00:00 2001 From: Jesse Plamondon-Willard Date: Sat, 22 Feb 2020 17:53:22 -0500 Subject: [PATCH 1/2] fix errors loading spouse room content packs in SMAPI 3.3 The new logic for loading map tilesheets incorrectly changed vanilla tilesheets like "townInterior" to "Maps/townInterior". While the game itself handled that, mods like Content Patcher which compared tilesheet paths would incorrectly decide that "townInterior" and "Maps/townInterior" were different files, and add a new tilesheet for it; that in turn would cause errors when patching spouse rooms, since it doesn't copy tilesheets. --- docs/release-notes.md | 3 +++ src/SMAPI.Toolkit/Utilities/PathUtilities.cs | 6 +++--- .../ContentManagers/ModContentManager.cs | 15 ++++++++++++--- 3 files changed, 18 insertions(+), 6 deletions(-) diff --git a/docs/release-notes.md b/docs/release-notes.md index 26515b619..d5def3518 100644 --- a/docs/release-notes.md +++ b/docs/release-notes.md @@ -1,6 +1,9 @@ ← [README](README.md) # Release notes +## Upcoming release +* Fixed errors with custom spouse room mods in SMAPI 3.3. + ## 3.3 Released 22 February 2020 for Stardew Valley 1.4.1 or later. diff --git a/src/SMAPI.Toolkit/Utilities/PathUtilities.cs b/src/SMAPI.Toolkit/Utilities/PathUtilities.cs index 40a59d879..e9d71747a 100644 --- a/src/SMAPI.Toolkit/Utilities/PathUtilities.cs +++ b/src/SMAPI.Toolkit/Utilities/PathUtilities.cs @@ -10,13 +10,13 @@ namespace StardewModdingAPI.Toolkit.Utilities public static class PathUtilities { /********* - ** Fields + ** Accessors *********/ /// The possible directory separator characters in a file path. - private static readonly char[] PossiblePathSeparators = new[] { '/', '\\', Path.DirectorySeparatorChar, Path.AltDirectorySeparatorChar }.Distinct().ToArray(); + public static readonly char[] PossiblePathSeparators = new[] { '/', '\\', Path.DirectorySeparatorChar, Path.AltDirectorySeparatorChar }.Distinct().ToArray(); /// The preferred directory separator character in an asset key. - private static readonly string PreferredPathSeparator = Path.DirectorySeparatorChar.ToString(); + public static readonly string PreferredPathSeparator = Path.DirectorySeparatorChar.ToString(); /********* diff --git a/src/SMAPI/Framework/ContentManagers/ModContentManager.cs b/src/SMAPI/Framework/ContentManagers/ModContentManager.cs index 7d274eb7d..4ffe3acd7 100644 --- a/src/SMAPI/Framework/ContentManagers/ModContentManager.cs +++ b/src/SMAPI/Framework/ContentManagers/ModContentManager.cs @@ -367,14 +367,23 @@ private bool TryGetTilesheetAssetName(string modRelativeMapFolder, string origin } // get from game assets + // Map tilesheet keys shouldn't include the "Maps/" prefix (the game will add it automatically) or ".png" extension. { - string contentKey = Path.Combine("Maps", relativePath); - if (contentKey.EndsWith(".png")) + string contentKey = relativePath; + foreach (char separator in PathUtilities.PossiblePathSeparators) + { + if (contentKey.StartsWith($"Maps{separator}")) + { + contentKey = contentKey.Substring(5); + break; + } + } + if (contentKey.EndsWith(".png", StringComparison.InvariantCultureIgnoreCase)) contentKey = contentKey.Substring(0, contentKey.Length - 4); try { - this.GameContentManager.Load(contentKey, this.Language, useCache: true); // no need to bypass cache here, since we're not storing the asset + this.GameContentManager.Load(Path.Combine("Maps", contentKey), this.Language, useCache: true); // no need to bypass cache here, since we're not storing the asset assetName = contentKey; return true; } From f9ffde9a3482b0d66bd6e30b41e890cb38b53af6 Mon Sep 17 00:00:00 2001 From: Jesse Plamondon-Willard Date: Sat, 22 Feb 2020 17:54:37 -0500 Subject: [PATCH 2/2] prepare for release --- docs/release-notes.md | 4 +++- src/SMAPI.Mods.ConsoleCommands/manifest.json | 4 ++-- src/SMAPI.Mods.SaveBackup/manifest.json | 4 ++-- src/SMAPI/Constants.cs | 2 +- 4 files changed, 8 insertions(+), 6 deletions(-) diff --git a/docs/release-notes.md b/docs/release-notes.md index d5def3518..cf0848561 100644 --- a/docs/release-notes.md +++ b/docs/release-notes.md @@ -1,7 +1,9 @@ ← [README](README.md) # Release notes -## Upcoming release +## 3.3.1 +Released 22 February 2020 for Stardew Valley 1.4.1 or later. + * Fixed errors with custom spouse room mods in SMAPI 3.3. ## 3.3 diff --git a/src/SMAPI.Mods.ConsoleCommands/manifest.json b/src/SMAPI.Mods.ConsoleCommands/manifest.json index 971c591a1..04f0c0591 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.3.0", + "Version": "3.3.1", "Description": "Adds SMAPI console commands that let you manipulate the game.", "UniqueID": "SMAPI.ConsoleCommands", "EntryDll": "ConsoleCommands.dll", - "MinimumApiVersion": "3.3.0" + "MinimumApiVersion": "3.3.1" } diff --git a/src/SMAPI.Mods.SaveBackup/manifest.json b/src/SMAPI.Mods.SaveBackup/manifest.json index 4559d1b0e..75b97566a 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.3.0", + "Version": "3.3.1", "Description": "Automatically backs up all your saves once per day into its folder.", "UniqueID": "SMAPI.SaveBackup", "EntryDll": "SaveBackup.dll", - "MinimumApiVersion": "3.3.0" + "MinimumApiVersion": "3.3.1" } diff --git a/src/SMAPI/Constants.cs b/src/SMAPI/Constants.cs index 670dc4945..e71b21b18 100644 --- a/src/SMAPI/Constants.cs +++ b/src/SMAPI/Constants.cs @@ -20,7 +20,7 @@ public static class Constants ** Public ****/ /// SMAPI's current semantic version. - public static ISemanticVersion ApiVersion { get; } = new Toolkit.SemanticVersion("3.3.0"); + public static ISemanticVersion ApiVersion { get; } = new Toolkit.SemanticVersion("3.3.1"); /// The minimum supported version of Stardew Valley. public static ISemanticVersion MinimumGameVersion { get; } = new GameVersion("1.4.1");