Skip to content

Commit a0beb10

Browse files
committed
handle textures whose assets no longer exist during asset propagation
Textures are reloaded in-place in Stardew Valley 1.6. That's much more efficient than the previous approach, but SMAPI can't take the game context into account anymore during asset propagation. That means textures which SMAPI would previously skip are now reloaded and may fail. For example, custom NPCs still exist in-memory when you return to title (since the game state isn't cleared yet), but often the mods which provide their portraits/sprites have unloaded their patches (e.g. because they depend on in-save Content Patcher tokens). This commit mitigates that by logging a small warning when it happens, instead of the giant exception trace it logs otherwise.
1 parent 2d178bb commit a0beb10

File tree

1 file changed

+12
-3
lines changed

1 file changed

+12
-3
lines changed

src/SMAPI/Metadata/CoreAssetPropagator.cs

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -167,9 +167,18 @@ private bool PropagateTexture(IAssetName assetName, LocalizedContentManager.Lang
167167
{
168168
if (contentManager.IsLoaded(assetName))
169169
{
170-
changed = true;
171-
Texture2D texture = contentManager.LoadLocalized<Texture2D>(assetName, language, useCache: true);
172-
texture.CopyFromTexture(newTexture.Value);
170+
if (this.DisposableContentManager.DoesAssetExist<Texture2D>(assetName))
171+
{
172+
changed = true;
173+
174+
Texture2D texture = contentManager.LoadLocalized<Texture2D>(assetName, language, useCache: true);
175+
texture.CopyFromTexture(newTexture.Value);
176+
}
177+
else
178+
{
179+
this.Monitor.Log($"Skipped reload for '{assetName.Name}' because the underlying asset no longer exists.", LogLevel.Warn);
180+
break;
181+
}
173182
}
174183
}
175184

0 commit comments

Comments
 (0)