dont reinsert into image cache. we want it to error there

This commit is contained in:
JohnCorby 2024-06-17 16:32:54 -07:00
parent d25a301cee
commit 37cad651f0
2 changed files with 1 additions and 4 deletions

View File

@ -542,13 +542,10 @@ namespace NewHorizons.Builder.Props
if (cacheExists) if (cacheExists)
{ {
// This code will execute in order to create the cache
// Loaders go sequentually - Load the inverted textures to the cache so that ImageUtilities will reuse them later
if (useInvertedCache) if (useInvertedCache)
{ {
invertedImageLoader.Start(true); invertedImageLoader.Start(true);
} }
// Atlas texture next so that the normal iamgeLoader knows not to regenerate them unless they were missing
if (useAtlasCache) if (useAtlasCache)
{ {
atlasImageLoader.Start(false); atlasImageLoader.Start(false);

View File

@ -13,7 +13,7 @@ namespace NewHorizons.Utility.Files
// key is path + applied effects // key is path + applied effects
private static readonly Dictionary<string, Texture> _textureCache = new(); private static readonly Dictionary<string, Texture> _textureCache = new();
public static bool CheckCachedTexture(string key, out Texture existingTexture) => _textureCache.TryGetValue(key, out existingTexture); public static bool CheckCachedTexture(string key, out Texture existingTexture) => _textureCache.TryGetValue(key, out existingTexture);
public static void TrackCachedTexture(string key, Texture texture) => _textureCache[key] = texture; public static void TrackCachedTexture(string key, Texture texture) => _textureCache.Add(key, texture); // dont reinsert cuz that causes memory leak!
public static string GetKey(string path) => public static string GetKey(string path) =>
path.Substring(Main.Instance.ModHelper.OwmlConfig.ModsPath.Length + 1).Replace('\\', '/'); path.Substring(Main.Instance.ModHelper.OwmlConfig.ModsPath.Length + 1).Replace('\\', '/');