summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJesse Plamondon-Willard <Pathoschild@users.noreply.github.com>2020-02-22 17:53:22 -0500
committerJesse Plamondon-Willard <Pathoschild@users.noreply.github.com>2020-02-22 17:53:22 -0500
commite8bb80af26997bc4e0ed43e4b2cc2cd5596e25f4 (patch)
tree5150a4ccd50b3de6aec6d9d37e53eced325049f7
parent66079f2253a0c81bb33c1fee848a6cd2222d43d9 (diff)
downloadSMAPI-e8bb80af26997bc4e0ed43e4b2cc2cd5596e25f4.tar.gz
SMAPI-e8bb80af26997bc4e0ed43e4b2cc2cd5596e25f4.tar.bz2
SMAPI-e8bb80af26997bc4e0ed43e4b2cc2cd5596e25f4.zip
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.
-rw-r--r--docs/release-notes.md3
-rw-r--r--src/SMAPI.Toolkit/Utilities/PathUtilities.cs6
-rw-r--r--src/SMAPI/Framework/ContentManagers/ModContentManager.cs15
3 files changed, 18 insertions, 6 deletions
diff --git a/docs/release-notes.md b/docs/release-notes.md
index 26515b61..d5def351 100644
--- a/docs/release-notes.md
+++ b/docs/release-notes.md
@@ -1,6 +1,9 @@
&larr; [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 40a59d87..e9d71747 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
*********/
/// <summary>The possible directory separator characters in a file path.</summary>
- private static readonly char[] PossiblePathSeparators = new[] { '/', '\\', Path.DirectorySeparatorChar, Path.AltDirectorySeparatorChar }.Distinct().ToArray();
+ public static readonly char[] PossiblePathSeparators = new[] { '/', '\\', Path.DirectorySeparatorChar, Path.AltDirectorySeparatorChar }.Distinct().ToArray();
/// <summary>The preferred directory separator character in an asset key.</summary>
- 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 7d274eb7..4ffe3acd 100644
--- a/src/SMAPI/Framework/ContentManagers/ModContentManager.cs
+++ b/src/SMAPI/Framework/ContentManagers/ModContentManager.cs
@@ -367,14 +367,23 @@ namespace StardewModdingAPI.Framework.ContentManagers
}
// 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<Texture2D>(contentKey, this.Language, useCache: true); // no need to bypass cache here, since we're not storing the asset
+ this.GameContentManager.Load<Texture2D>(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;
}