summaryrefslogtreecommitdiff
path: root/src/SMAPI
diff options
context:
space:
mode:
authorJesse Plamondon-Willard <Pathoschild@users.noreply.github.com>2020-01-04 22:08:01 -0500
committerJesse Plamondon-Willard <Pathoschild@users.noreply.github.com>2020-01-04 22:08:01 -0500
commit93459a5e37b26cc8d742878dd993543c43f70694 (patch)
treeb1509194189f667d2de994c491f3872ff238c7ce /src/SMAPI
parentaef2550d23e5cf61adb699d90f39f5799db29bdf (diff)
downloadSMAPI-93459a5e37b26cc8d742878dd993543c43f70694.tar.gz
SMAPI-93459a5e37b26cc8d742878dd993543c43f70694.tar.bz2
SMAPI-93459a5e37b26cc8d742878dd993543c43f70694.zip
fix new asset invalidation code not correctly handling interceptors which both load and edit
Diffstat (limited to 'src/SMAPI')
-rw-r--r--src/SMAPI/Framework/Content/AssetInterceptorChange.cs6
-rw-r--r--src/SMAPI/Framework/SGame.cs20
2 files changed, 18 insertions, 8 deletions
diff --git a/src/SMAPI/Framework/Content/AssetInterceptorChange.cs b/src/SMAPI/Framework/Content/AssetInterceptorChange.cs
index 498afe36..037d9f89 100644
--- a/src/SMAPI/Framework/Content/AssetInterceptorChange.cs
+++ b/src/SMAPI/Framework/Content/AssetInterceptorChange.cs
@@ -64,7 +64,8 @@ namespace StardewModdingAPI.Framework.Content
{
try
{
- return editor.CanEdit<TAsset>(asset);
+ if (editor.CanEdit<TAsset>(asset))
+ return true;
}
catch (Exception ex)
{
@@ -77,7 +78,8 @@ namespace StardewModdingAPI.Framework.Content
{
try
{
- return loader.CanLoad<TAsset>(asset);
+ if (loader.CanLoad<TAsset>(asset))
+ return true;
}
catch (Exception ex)
{
diff --git a/src/SMAPI/Framework/SGame.cs b/src/SMAPI/Framework/SGame.cs
index e2b22ba7..d6c3b836 100644
--- a/src/SMAPI/Framework/SGame.cs
+++ b/src/SMAPI/Framework/SGame.cs
@@ -18,6 +18,7 @@ using StardewModdingAPI.Framework.Events;
using StardewModdingAPI.Framework.Input;
using StardewModdingAPI.Framework.Networking;
using StardewModdingAPI.Framework.Reflection;
+using StardewModdingAPI.Framework.StateTracking.Comparers;
using StardewModdingAPI.Framework.StateTracking.Snapshots;
using StardewModdingAPI.Framework.Utilities;
using StardewModdingAPI.Toolkit.Serialization;
@@ -427,17 +428,24 @@ namespace StardewModdingAPI.Framework
return;
}
-
/*********
** Reload assets when interceptors are added/removed
*********/
if (this.ReloadAssetInterceptorsQueue.Any())
{
- this.Monitor.Log("Invalidating cached assets for new editors & loaders...", LogLevel.Trace);
+ // get unique interceptors
+ AssetInterceptorChange[] interceptors = this.ReloadAssetInterceptorsQueue
+ .GroupBy(p => p.Instance, new ObjectReferenceComparer<object>())
+ .Select(p => p.First())
+ .ToArray();
+ this.ReloadAssetInterceptorsQueue.Clear();
+
+ // log summary
+ this.Monitor.Log("Invalidating cached assets for new editors & loaders...");
this.Monitor.Log(
- "changed: "
+ " changed: "
+ string.Join(", ",
- this.ReloadAssetInterceptorsQueue
+ interceptors
.GroupBy(p => p.Mod)
.OrderBy(p => p.Key.DisplayName)
.Select(modGroup =>
@@ -448,8 +456,8 @@ namespace StardewModdingAPI.Framework
)
);
- this.ContentCore.InvalidateCache(asset => this.ReloadAssetInterceptorsQueue.Any(p => p.CanIntercept(asset)));
- this.ReloadAssetInterceptorsQueue.Clear();
+ // reload affected assets
+ this.ContentCore.InvalidateCache(asset => interceptors.Any(p => p.CanIntercept(asset)));
}
/*********