summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--docs/release-notes.md1
-rw-r--r--src/SMAPI/Framework/ContentManagers/GameContentManager.cs12
2 files changed, 12 insertions, 1 deletions
diff --git a/docs/release-notes.md b/docs/release-notes.md
index 5f964cfd..01b48998 100644
--- a/docs/release-notes.md
+++ b/docs/release-notes.md
@@ -59,6 +59,7 @@ These changes have not been released yet.
* Removed the `Monitor.ExitGameImmediately` method.
* Updated dependencies (including Json.NET 11.0.2 → 12.0.2, Mono.Cecil 0.10.1 → 0.10.4).
* Fixed issue where mod changes weren't tracked correctly for raising events in some cases. Events now reflect a frozen snapshot of the game state, and any mod changes are reflected in the next event tick.
+ * Fixed issue where, when a mod's `IAssetEditor` uses `asset.ReplaceWith` on a texture asset while playing in non-English, any changes from that point won't affect subsequent cached asset loads.
* Fixed `LoadStageChanged` event not raising correct flags in some cases when creating a new save.
## 2.11.3
diff --git a/src/SMAPI/Framework/ContentManagers/GameContentManager.cs b/src/SMAPI/Framework/ContentManagers/GameContentManager.cs
index c64e9ba9..0b563555 100644
--- a/src/SMAPI/Framework/ContentManagers/GameContentManager.cs
+++ b/src/SMAPI/Framework/ContentManagers/GameContentManager.cs
@@ -184,10 +184,20 @@ namespace StardewModdingAPI.Framework.ContentManagers
return;
}
}
+
+ // save to cache
+ // Note: even if the asset was loaded and cached right before this method was called,
+ // we need to fully re-inject it here for two reasons:
+ // 1. So we can look up an asset by its base or localized key (the game/XNA logic
+ // only caches by the most specific key).
+ // 2. Because a mod asset loader/editor may have changed the asset in a way that
+ // doesn't change the instance stored in the cache, e.g. using `asset.ReplaceWith`.
+ string keyWithLocale = $"{assetName}.{this.GetLocale(language)}";
base.Inject(assetName, value, language);
+ if (this.Cache.ContainsKey(keyWithLocale))
+ base.Inject(keyWithLocale, value, language);
// track whether the injected asset is translatable for is-loaded lookups
- string keyWithLocale = $"{assetName}.{this.GetLocale(language)}";
if (this.Cache.ContainsKey(keyWithLocale))
{
this.IsLocalizableLookup[assetName] = true;