summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--docs/release-notes.md7
-rw-r--r--src/SMAPI/Framework/ModHelpers/ContentHelper.cs14
2 files changed, 17 insertions, 4 deletions
diff --git a/docs/release-notes.md b/docs/release-notes.md
index 6a827b0f..2a50c045 100644
--- a/docs/release-notes.md
+++ b/docs/release-notes.md
@@ -19,9 +19,10 @@
* Fixed `e.SuppressButton()` not correctly suppressing keyboard buttons.
* Fixed `e.IsClick` (now `e.IsActionButton`) ignoring custom key bindings.
* `SemanticVersion` can now be constructed from a `System.Version`.
- * Fixed custom map tilesheets not working unless they're explicitly loaded first.
- * Fixed mods which implement `IAssetLoader` directly not being allowed to load files due to incorrect conflict detection.
- * Fixed SMAPI blocking reflection access to vanilla members on overridden types.
+ * Fixed reflection API blocking access to vanilla members on overridden types.
+ * Fixed content API allowing absolute paths as asset keys.
+ * Fixed content API failing to load custom map tilesheets that aren't preloaded.
+ * Fixed content API incorrectly detecting duplicate loaders when a mod implements `IAssetLoader` directly.
* For SMAPI developers:
* Added the SMAPI installer version and platform to the window title to simplify troubleshooting.
diff --git a/src/SMAPI/Framework/ModHelpers/ContentHelper.cs b/src/SMAPI/Framework/ModHelpers/ContentHelper.cs
index 711897eb..be9594ee 100644
--- a/src/SMAPI/Framework/ModHelpers/ContentHelper.cs
+++ b/src/SMAPI/Framework/ModHelpers/ContentHelper.cs
@@ -1,6 +1,7 @@
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
+using System.Diagnostics.CodeAnalysis;
using System.IO;
using System.Linq;
using Microsoft.Xna.Framework.Content;
@@ -88,7 +89,7 @@ namespace StardewModdingAPI.Framework.ModHelpers
try
{
- this.ContentManager.AssertValidAssetKeyFormat(key);
+ this.AssertValidAssetKeyFormat(key);
switch (source)
{
case ContentSource.GameContent:
@@ -189,6 +190,17 @@ namespace StardewModdingAPI.Framework.ModHelpers
/*********
** Private methods
*********/
+ /// <summary>Assert that the given key has a valid format.</summary>
+ /// <param name="key">The asset key to check.</param>
+ /// <exception cref="ArgumentException">The asset key is empty or contains invalid characters.</exception>
+ [SuppressMessage("ReSharper", "ParameterOnlyUsedForPreconditionCheck.Local", Justification = "Parameter is only used for assertion checks by design.")]
+ private void AssertValidAssetKeyFormat(string key)
+ {
+ this.ContentManager.AssertValidAssetKeyFormat(key);
+ if (Path.IsPathRooted(key))
+ throw new ArgumentException("The asset key must not be an absolute path.");
+ }
+
/// <summary>Fix custom map tilesheet paths so they can be found by the content manager.</summary>
/// <param name="map">The map whose tilesheets to fix.</param>
/// <param name="mapKey">The map asset key within the mod folder.</param>