From 2f279708b3529020ac0630fe96b8dd456e9cb509 Mon Sep 17 00:00:00 2001 From: Jesse Plamondon-Willard Date: Fri, 4 Mar 2022 20:21:14 -0500 Subject: fix regression with mod XNB files in the content pipeline (#766) --- src/SMAPI/Framework/ContentManagers/ModContentManager.cs | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) (limited to 'src/SMAPI/Framework/ContentManagers/ModContentManager.cs') 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(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(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(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; -- cgit