From 6292b21f220d1936f8d2a5e1c883c9664be4973d Mon Sep 17 00:00:00 2001 From: Jesse Plamondon-Willard Date: Sat, 2 Apr 2022 14:59:09 -0400 Subject: fix tick cache using game ticks instead of SMAPI ticks The game ticks aren't incremented consistently in some cases (e.g. while loading a save), which leads to the cache values being kept too long. --- src/SMAPI/Framework/Utilities/TickCacheDictionary.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'src/SMAPI/Framework/Utilities') diff --git a/src/SMAPI/Framework/Utilities/TickCacheDictionary.cs b/src/SMAPI/Framework/Utilities/TickCacheDictionary.cs index 1613a480..5921e089 100644 --- a/src/SMAPI/Framework/Utilities/TickCacheDictionary.cs +++ b/src/SMAPI/Framework/Utilities/TickCacheDictionary.cs @@ -13,7 +13,7 @@ namespace StardewModdingAPI.Framework.Utilities ** Fields *********/ /// The last game tick for which data was cached. - private int LastGameTick = -1; + private uint? LastGameTick; /// The underlying cached data. private readonly Dictionary Cache = new(); @@ -28,10 +28,10 @@ namespace StardewModdingAPI.Framework.Utilities public TValue GetOrSet(TKey cacheKey, Func get) { // clear cache on new tick - if (Game1.ticks != this.LastGameTick) + if (SCore.TicksElapsed != this.LastGameTick) { this.Cache.Clear(); - this.LastGameTick = Game1.ticks; + this.LastGameTick = SCore.TicksElapsed; } // fetch value -- cgit