From 1b13d92b9949c67adb886d54e11b0144eac3985c Mon Sep 17 00:00:00 2001 From: Jarrod Doyle Date: Mon, 23 Dec 2024 19:36:28 +0000 Subject: [PATCH] Fix #5: Cull any gamesys links/linkdata with concrete LinkIDs --- KeepersCompound.LGS/Database/Chunks/Link.cs | 32 +++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/KeepersCompound.LGS/Database/Chunks/Link.cs b/KeepersCompound.LGS/Database/Chunks/Link.cs index 4cee3b4..7faa6c5 100644 --- a/KeepersCompound.LGS/Database/Chunks/Link.cs +++ b/KeepersCompound.LGS/Database/Chunks/Link.cs @@ -83,6 +83,22 @@ public class LinkChunk : IChunk, IMergable public void Merge(IMergable other) { + // !HACK: We always merge into gamesys so we can pre-trim garbage here + var count = links.Count; + for (var i = count - 1; i >= 0; i--) + { + var link = links[i]; + if (link.linkId.IsConcrete()) + { + links.RemoveAt(i); + } + } + + if (links.Count != count) + { + Console.WriteLine($"Trimmed links: {count} -> {links.Count}"); + } + links.AddRange(((LinkChunk)other).links); } } @@ -133,6 +149,22 @@ public class LinkDataMetaProp : IChunk, IMergable public void Merge(IMergable other) { + // !HACK: We always merge into gamesys so we can pre-trim garbage here + var count = linkData.Count; + for (var i = count - 1; i >= 0; i--) + { + var link = linkData[i]; + if (link.linkId.IsConcrete()) + { + linkData.RemoveAt(i); + } + } + + if (linkData.Count != count) + { + Console.WriteLine($"Trimmed link data: {count} -> {linkData.Count}"); + } + linkData.AddRange(((LinkDataMetaProp)other).linkData); } } \ No newline at end of file