summaryrefslogtreecommitdiff
path: root/src/SMAPI
diff options
context:
space:
mode:
authorJesse Plamondon-Willard <Pathoschild@users.noreply.github.com>2022-04-02 14:59:09 -0400
committerJesse Plamondon-Willard <Pathoschild@users.noreply.github.com>2022-04-02 14:59:09 -0400
commit6292b21f220d1936f8d2a5e1c883c9664be4973d (patch)
treeb779f274909c75cb79a896b09b61b94bdd1ec06c /src/SMAPI
parent4e2d7f2550b05e410735f51beac76ed040178cf4 (diff)
downloadSMAPI-6292b21f220d1936f8d2a5e1c883c9664be4973d.tar.gz
SMAPI-6292b21f220d1936f8d2a5e1c883c9664be4973d.tar.bz2
SMAPI-6292b21f220d1936f8d2a5e1c883c9664be4973d.zip
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.
Diffstat (limited to 'src/SMAPI')
-rw-r--r--src/SMAPI/Framework/Utilities/TickCacheDictionary.cs6
1 files changed, 3 insertions, 3 deletions
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
*********/
/// <summary>The last game tick for which data was cached.</summary>
- private int LastGameTick = -1;
+ private uint? LastGameTick;
/// <summary>The underlying cached data.</summary>
private readonly Dictionary<TKey, TValue> Cache = new();
@@ -28,10 +28,10 @@ namespace StardewModdingAPI.Framework.Utilities
public TValue GetOrSet(TKey cacheKey, Func<TValue> 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