Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Maple2.File.Parser/Maple2.File.Parser.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
<PackageTags>MapleStory2, File, Parser, m2d, xml</PackageTags>
<!-- Use following lines to write the generated files to disk. -->
<EmitCompilerGeneratedFiles Condition=" '$(Configuration)' == 'Debug' ">true</EmitCompilerGeneratedFiles>
<PackageVersion>2.3.2</PackageVersion>
<PackageVersion>2.3.3</PackageVersion>
<TargetFramework>net8.0</TargetFramework>
<PackageReadmeFile>README.md</PackageReadmeFile>
<ImplicitUsings>enable</ImplicitUsings>
Expand Down
23 changes: 23 additions & 0 deletions Maple2.File.Parser/ServerTableParser.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,17 @@
using Maple2.File.IO;
using Maple2.File.Parser.Enum;
using Maple2.File.Parser.Tools;
using Maple2.File.Parser.Xml.Table;
using Maple2.File.Parser.Xml.Table.Server;
using Fish = Maple2.File.Parser.Xml.Table.Server.Fish;
using FishingSpot = Maple2.File.Parser.Xml.Table.Server.FishingSpot;
using FishingSpotRoot = Maple2.File.Parser.Xml.Table.Server.FishingSpotRoot;
using FishRoot = Maple2.File.Parser.Xml.Table.Server.FishRoot;
using IndividualItemDrop = Maple2.File.Parser.Xml.Table.Server.IndividualItemDrop;
using IndividualItemDropRoot = Maple2.File.Parser.Xml.Table.Server.IndividualItemDropRoot;
using ItemMergeOptionRoot = Maple2.File.Parser.Xml.Table.Server.ItemMergeOptionRoot;
using ItemOptionVariation = Maple2.File.Parser.Xml.Table.Server.ItemOptionVariation;
using MergeOption = Maple2.File.Parser.Xml.Table.Server.MergeOption;

namespace Maple2.File.Parser;

Expand Down Expand Up @@ -48,6 +58,7 @@ public class ServerTableParser {
private readonly XmlSerializer itemOptionProbabilitySerializer;
private readonly XmlSerializer itemOptionVariationSerializer;
private readonly XmlSerializer itemOptionRandomSerializer;
private readonly XmlSerializer constantsSerializer;

public ServerTableParser(M2dReader xmlReader) {
this.xmlReader = xmlReader;
Expand Down Expand Up @@ -89,6 +100,7 @@ public ServerTableParser(M2dReader xmlReader) {
itemOptionProbabilitySerializer = new XmlSerializer(typeof(ItemOptionProbabilityRoot));
itemOptionVariationSerializer = new XmlSerializer(typeof(ItemOptionVariationRoot));
itemOptionRandomSerializer = new XmlSerializer(typeof(ItemOptionRandomRoot));
constantsSerializer = new XmlSerializer(typeof(Constants));

// var seen = new HashSet<string>();
// this.bankTypeSerializer.UnknownAttribute += (sender, args) => {
Expand Down Expand Up @@ -679,4 +691,15 @@ public ServerTableParser(M2dReader xmlReader) {
yield return (option.code, option);
}
}

public IEnumerable<(string Key, Constants.Key key)> ParseConstants() {
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);
}
}
}
10 changes: 10 additions & 0 deletions Maple2.File.Tests/ServerTableParserTest.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using Maple2.File.Parser;
using Maple2.File.Parser.Xml.Table;
using Microsoft.VisualStudio.TestTools.UnitTesting;

namespace Maple2.File.Tests;
Expand Down Expand Up @@ -435,5 +436,14 @@ public void TestItemOptionRandom() {
continue;
}
}

[TestMethod]
public void TestConstants() {
var parser = new ServerTableParser(TestUtils.ServerReader);

foreach ((_, _) in parser.ParseConstants()) {
continue;
}
}
}

Loading