From 9e45a149eeb5d24c1c25b1815920c8268f27dc9a Mon Sep 17 00:00:00 2001 From: Zin <62830952+Zintixx@users.noreply.github.com> Date: Sat, 28 Nov 2026 08:40:48 -0800 Subject: [PATCH] Expose table/Server/constants.xml rows before feature resolution ParseConstants drops a key whose rows are all gated on a disabled feature, so a consumer cannot tell that key apart from one the file never had. ParseConstantsUnresolved returns every row with its feature and locale. Co-Authored-By: Claude Opus 5.5 --- Maple2.File.Parser/Maple2.File.Parser.csproj | 2 +- Maple2.File.Parser/ServerTableParser.cs | 19 +++++++++++++++---- Maple2.File.Tests/ServerTableParserTest.cs | 13 +++++++++++++ 3 files changed, 29 insertions(+), 5 deletions(-) diff --git a/Maple2.File.Parser/Maple2.File.Parser.csproj b/Maple2.File.Parser/Maple2.File.Parser.csproj index f573446..87c2fb6 100644 --- a/Maple2.File.Parser/Maple2.File.Parser.csproj +++ b/Maple2.File.Parser/Maple2.File.Parser.csproj @@ -13,7 +13,7 @@ MapleStory2, File, Parser, m2d, xml true - 2.4.41 + 2.4.42 net8.0 README.md enable diff --git a/Maple2.File.Parser/ServerTableParser.cs b/Maple2.File.Parser/ServerTableParser.cs index 27e41ed..c044eda 100644 --- a/Maple2.File.Parser/ServerTableParser.cs +++ b/Maple2.File.Parser/ServerTableParser.cs @@ -746,14 +746,25 @@ public IEnumerable ParseGlobalEquipmentRankProba } public IEnumerable<(string Key, Constants.Key key)> ParseConstants() { + foreach (Constants.Key key in DeserializeConstants().v) { + yield return (key.key, key); + } + } + + // Every row, before feature and locale resolution. A key gated on a disabled feature is absent + // from ParseConstants; this tells that apart from a key the file does not have. + public IEnumerable<(string Key, Constants.Key key)> ParseConstantsUnresolved() { + foreach (Constants.Key key in DeserializeConstants().__v) { + yield return (key.key, key); + } + } + + private Constants DeserializeConstants() { string xml = Sanitizer.RemoveEmpty(xmlReader.GetString(xmlReader.GetEntry("table/Server/constants.xml"))); var reader = XmlReader.Create(new StringReader(xml)); var data = constantsSerializer.Deserialize(reader) as Constants; Debug.Assert(data != null); - - foreach (Constants.Key key in data.v) { - yield return (key.key, key); - } + return data; } public IEnumerable ParseNpcStatFactorByPlayerCount() { diff --git a/Maple2.File.Tests/ServerTableParserTest.cs b/Maple2.File.Tests/ServerTableParserTest.cs index 2ce4f7f..696a5c4 100644 --- a/Maple2.File.Tests/ServerTableParserTest.cs +++ b/Maple2.File.Tests/ServerTableParserTest.cs @@ -551,6 +551,19 @@ public void TestConstants() { } } + [TestMethod] + public void TestConstantsUnresolved() { + var parser = new ServerTableParser(TestUtils.ServerReader); + + List unresolved = parser.ParseConstantsUnresolved().Select(entry => entry.key).ToList(); + foreach ((_, Constants.Key key) in parser.ParseConstants()) { + Assert.IsTrue(unresolved.Any(row => row.key == key.key && row.value == key.value && row.Feature == key.Feature && row.Locale == key.Locale), + $"resolved row {key.key} is missing from the unresolved rows"); + } + // constants.xml gates the Sky Fortress keys on FameContents. + Assert.IsTrue(unresolved.Any(key => key.key == "FameContentsRequireQuestID" && key.Feature == "FameContents")); + } + [TestMethod] public void TestNpcStatFactorByPlayerCount() { var parser = new ServerTableParser(TestUtils.ServerReader);