Skip to content

Commit

Permalink
Remove settings for overlays that no longer exist
Browse files Browse the repository at this point in the history
  • Loading branch information
ngld committed Dec 8, 2021
1 parent de818f2 commit 9f98ec3
Showing 1 changed file with 28 additions and 0 deletions.
28 changes: 28 additions & 0 deletions OverlayPlugin.Core/EventSources/BuiltinEventConfig.cs
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,34 @@ public static BuiltinEventConfig LoadConfig(IPluginConfig Config)
if (obj.TryGetValue("OverlayData", out value))
{
result.OverlayData = value.ToObject<Dictionary<string, JToken>>();

// Remove data for overlays that no longer exist.
var obsoleteKeys = new List<string>();
var overlayUUIDs = new List<string>();

foreach (var overlay in Config.Overlays)
{
if (overlay is Overlays.MiniParseOverlayConfig)
{
overlayUUIDs.Add(((Overlays.MiniParseOverlayConfig)overlay).Uuid.ToString());
}
}

foreach (var key in result.OverlayData.Keys)
{
if (!key.StartsWith("overlay#")) continue;

var uuid = key.Substring(8, 36);
if (!overlayUUIDs.Contains(uuid))
{
obsoleteKeys.Add(key);
}
}

foreach (var key in obsoleteKeys)
{
result.OverlayData.Remove(key);
}
}

if (obj.TryGetValue("LogLines", out value))
Expand Down

0 comments on commit 9f98ec3

Please sign in to comment.