cache now gets written to file when body building is successful

This commit is contained in:
FreezeDriedMangoes 2023-01-30 22:52:43 -05:00
parent c9e46050d2
commit c7f12c967b
2 changed files with 4 additions and 2 deletions

View File

@ -273,7 +273,7 @@ namespace NewHorizons.Handlers
Logger.LogError($"Error in event handler for OnPlanetLoaded on body {body.Config.name}: {e}"); Logger.LogError($"Error in event handler for OnPlanetLoaded on body {body.Config.name}: {e}");
} }
body.UnloadCache(); body.UnloadCache(true);
return true; return true;
} }

View File

@ -28,8 +28,10 @@ namespace NewHorizons.Utility
if (RelativePath != null) Cache = new Cache(RelativePath+".nhcache"); if (RelativePath != null) Cache = new Cache(RelativePath+".nhcache");
} }
public void UnloadCache() public void UnloadCache(bool writeBeforeUnload=false)
{ {
if (writeBeforeUnload) Cache.WriteToFile();
Cache = null; // garbage collection will take care of it Cache = null; // garbage collection will take care of it
} }
#endregion Cache #endregion Cache