diff options
author | Jesse Plamondon-Willard <Pathoschild@users.noreply.github.com> | 2022-03-04 20:21:14 -0500 |
---|---|---|
committer | Jesse Plamondon-Willard <Pathoschild@users.noreply.github.com> | 2022-03-05 15:30:17 -0500 |
commit | 2f279708b3529020ac0630fe96b8dd456e9cb509 (patch) | |
tree | 818c5240086cb8912be5919576eb147180e83ccb /src/SMAPI/Framework/ContentManagers/ModContentManager.cs | |
parent | c2086216fa0df15cb7e8035465996d6fcfdf6448 (diff) | |
download | SMAPI-2f279708b3529020ac0630fe96b8dd456e9cb509.tar.gz SMAPI-2f279708b3529020ac0630fe96b8dd456e9cb509.tar.bz2 SMAPI-2f279708b3529020ac0630fe96b8dd456e9cb509.zip |
fix regression with mod XNB files in the content pipeline (#766)
Diffstat (limited to 'src/SMAPI/Framework/ContentManagers/ModContentManager.cs')
-rw-r--r-- | src/SMAPI/Framework/ContentManagers/ModContentManager.cs | 14 |
1 files changed, 9 insertions, 5 deletions
diff --git a/src/SMAPI/Framework/ContentManagers/ModContentManager.cs b/src/SMAPI/Framework/ContentManagers/ModContentManager.cs index 50ea6e61..2c47f14c 100644 --- a/src/SMAPI/Framework/ContentManagers/ModContentManager.cs +++ b/src/SMAPI/Framework/ContentManagers/ModContentManager.cs @@ -79,7 +79,6 @@ namespace StardewModdingAPI.Framework.ContentManagers public override T Load<T>(string assetName, LanguageCode language, bool useCache) { // normalize key - bool isXnbFile = Path.GetExtension(assetName).ToLower() == ".xnb"; IAssetName parsedName = this.Coordinator.ParseAssetName(assetName); // disable caching @@ -111,7 +110,7 @@ namespace StardewModdingAPI.Framework.ContentManagers try { // get file - FileInfo file = this.GetModFile(isXnbFile ? $"{parsedName}.xnb" : parsedName.Name); // .xnb extension is stripped from asset names passed to the content manager + FileInfo file = this.GetModFile(parsedName.Name); if (!file.Exists) throw GetContentError("the specified path doesn't exist."); @@ -121,11 +120,16 @@ namespace StardewModdingAPI.Framework.ContentManagers // XNB file case ".xnb": { - asset = this.RawLoad<T>(parsedName.Name, useCache: false); + // the underlying content manager adds a .xnb extension implicitly, so + // we need to strip it here to avoid trying to load a '.xnb.xnb' file. + string loadName = parsedName.Name[..^".xnb".Length]; + + // load asset + asset = this.RawLoad<T>(loadName, useCache: false); if (asset is Map map) { - map.assetPath = parsedName.Name; - this.FixTilesheetPaths(map, relativeMapPath: parsedName.Name, fixEagerPathPrefixes: true); + map.assetPath = loadName; + this.FixTilesheetPaths(map, relativeMapPath: loadName, fixEagerPathPrefixes: true); } } break; |