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);