summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJesse Plamondon-Willard <github@jplamondonw.com>2017-05-27 01:01:45 -0400
committerJesse Plamondon-Willard <github@jplamondonw.com>2017-05-27 01:01:45 -0400
commit55fa8198ffc140237e1041056f3a4d8f4e7469c8 (patch)
tree28b0089b9b94e1fc79e7f64f5a3ec673e9b6656f
parente92dbc41df1548b72be4ca5c0a6c6fe17235d950 (diff)
downloadSMAPI-55fa8198ffc140237e1041056f3a4d8f4e7469c8.tar.gz
SMAPI-55fa8198ffc140237e1041056f3a4d8f4e7469c8.tar.bz2
SMAPI-55fa8198ffc140237e1041056f3a4d8f4e7469c8.zip
fix content API not matching XNB files with two dots (like 'a.b.xnb') if extension isn't specified
-rw-r--r--release-notes.md1
-rw-r--r--src/StardewModdingAPI/Framework/ContentHelper.cs12
2 files changed, 11 insertions, 2 deletions
diff --git a/release-notes.md b/release-notes.md
index deab5cfe..622fcd49 100644
--- a/release-notes.md
+++ b/release-notes.md
@@ -31,6 +31,7 @@ For modders:
<small>_When loading a map from the mod folder, SMAPI will automatically use tilesheets relative to the map file if they exists. Otherwise it will default to tilesheets in the game content._</small>
* Added `Context.IsInDrawLoop` for specialised mods.
* Fixed `smapi-crash.txt` being copied from the default log even if a different path is specified with `--log-path`.
+* Fixed the content API not matching XNB filenames with two dots (like `a.b.xnb`) if you don't specify the `.xnb` extension.
## 1.13.1
See [log](https://github.com/Pathoschild/SMAPI/compare/1.13...1.13.1).
diff --git a/src/StardewModdingAPI/Framework/ContentHelper.cs b/src/StardewModdingAPI/Framework/ContentHelper.cs
index 14b6aa8f..7fd5e803 100644
--- a/src/StardewModdingAPI/Framework/ContentHelper.cs
+++ b/src/StardewModdingAPI/Framework/ContentHelper.cs
@@ -225,10 +225,18 @@ namespace StardewModdingAPI.Framework
/// <param name="path">The asset path relative to the mod folder.</param>
private FileInfo GetModFile(string path)
{
+ // try exact match
path = Path.Combine(this.ModFolderPath, this.ContentManager.NormalisePathSeparators(path));
FileInfo file = new FileInfo(path);
- if (!file.Exists && file.Extension == "")
- file = new FileInfo(Path.Combine(this.ModFolderPath, path + ".xnb"));
+
+ // try with default extension
+ if (!file.Exists && file.Extension.ToLower() != ".xnb")
+ {
+ FileInfo result = new FileInfo(path + ".xnb");
+ if (result.Exists)
+ file = result;
+ }
+
return file;
}