Skip to content

Commit

Permalink
[KK,KKS] Purge overlays for coords that no longer exist
Browse files Browse the repository at this point in the history
  • Loading branch information
ManlyMarco committed Dec 21, 2021
1 parent 40fc3fc commit e4d78fe
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion Core_OverlayMods/OverlayStorage.cs
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ public void Load(PluginData data)
// If anything goes wrong, make sure we are in a sane state
Clear();
}

public void Load(Dictionary<CoordinateType, Dictionary<TexType, byte[]>> overlays)
{
Clear();
Expand Down Expand Up @@ -171,6 +171,16 @@ public void Save(PluginData data)

private void PurgeUnused()
{
#if KK || KKS
var unusedCoords = _allOverlayTextures.Keys.Where(x => (int)x >= _chaControl.chaFile.coordinate.Length).ToList();
if (unusedCoords.Count > 0)
{
KoiSkinOverlayMgr.Logger.LogWarning($"Removing data for missing coordinates: {string.Join(", ", unusedCoords.Select(x => x.ToString()).ToArray())}");
foreach (var unusedCoord in unusedCoords)
_allOverlayTextures.Remove(unusedCoord);
}
#endif

_textureStorage.PurgeUnused(_allOverlayTextures.SelectMany(x => x.Value.Values));

var allTextures = _textureStorage.GetAllTextureIDs();
Expand Down

0 comments on commit e4d78fe

Please sign in to comment.