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.4.41</PackageVersion>
<PackageVersion>2.4.42</PackageVersion>
<TargetFramework>net8.0</TargetFramework>
<PackageReadmeFile>README.md</PackageReadmeFile>
<ImplicitUsings>enable</ImplicitUsings>
Expand Down
11 changes: 11 additions & 0 deletions Maple2.File.Parser/TableParser.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1475,6 +1475,17 @@ public IEnumerable<JobTableNew> ParseJobTableNew() {
}
}

public IEnumerable<(int PetId, IReadOnlyList<int> FieldIds)> ParseFieldMetaDataPet() {
string xml = Sanitizer.RemoveEmpty(xmlReader.GetString(xmlReader.GetEntry($"table/{locale}/fieldmetadata.xml")));
var reader = XmlReader.Create(new StringReader(xml));
var data = fieldMetaDataSerializer.Deserialize(reader) as FieldMetaDataRoot;
Debug.Assert(data != null);

foreach (FieldPet entry in data.pet) {
yield return (entry.id, entry.field.Select(field => field.id).ToList());
}
}

public IEnumerable<(string Feature, IList<WorldMap.Map> Maps)> ParseWorldMap() {
string xml = Sanitizer.RemoveEmpty(xmlReader.GetString(xmlReader.GetEntry($"table/{locale}/newworldmap.xml")));
var reader = XmlReader.Create(new StringReader(xml));
Expand Down
16 changes: 14 additions & 2 deletions Maple2.File.Parser/Xml/Table/FieldMetaData.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,23 @@ namespace Maple2.File.Parser.Xml.Table;

// ./data/xml/table/na/fieldmetadata.xml
//
// Only the <fieldPortal> section is modelled. The file also carries <npc>, <interactObject>,
// <fluid>, <liftable>, <pet> and <taxiStation> sections, which nothing consumes yet.
// Only the <fieldPortal> and <pet> sections are modelled. The file also carries <npc>,
// <interactObject>, <fluid>, <liftable> and <taxiStation> sections, which nothing consumes yet.
[XmlRoot("ms2")]
public partial class FieldMetaDataRoot {
[M2dFeatureLocale(Selector = "field")] private IList<FieldPortal> _fieldPortal;
[XmlElement] public List<FieldPet> pet = new();
}

// The maps a tamable pet lives on. table/petspawninfo.xml has no row for some of these pairs,
// such as every Kritias pet (PrivateMaple2 #2393).
public partial class FieldPet {
[XmlAttribute] public int id;
[XmlElement] public List<Field> field = new();

public partial class Field {
[XmlAttribute] public int id;
}
}

// The client builds its sub-map to exploration-zone table from these entries: portals with
Expand Down
12 changes: 12 additions & 0 deletions Maple2.File.Tests/TableParserTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -738,6 +738,18 @@ public void TestFieldMetaData() {
Assert.IsFalse(entries.ContainsKey(84000001));
}

[TestMethod]
public void TestFieldMetaDataPet() {
Dictionary<int, IReadOnlyList<int>> pets = _parser.ParseFieldMetaDataPet()
.ToDictionary(result => result.PetId, result => result.FieldIds);

// Expected values read from table/na/fieldmetadata.xml.
Assert.AreEqual(39, pets.Count);
CollectionAssert.AreEqual(new[] { 2000014, 2000017, 2000041, 63000056 }, pets[61000002].ToArray());
CollectionAssert.AreEqual(new[] { 2020001 }, pets[61000159].ToArray());
CollectionAssert.AreEqual(new[] { 2020008, 2020014 }, pets[61000167].ToArray());
}

[TestMethod]
public void TestWorldMap() {
foreach ((_, _) in _parser.ParseWorldMap()) {
Expand Down
Loading