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
12 changes: 8 additions & 4 deletions Maple2.File.Parser/AiParser.cs
Original file line number Diff line number Diff line change
Expand Up @@ -40,27 +40,31 @@ public AiParser(M2dReader xmlReader, bool includeComments = false) {
}
XmlNode? battleNode = document.SelectSingleNode("npcAi/battle");
if (battleNode != null) {
ai.Battle.startAni = battleNode.Attributes?["startAni"]?.Value ?? string.Empty;
ai.Battle.endAni = battleNode.Attributes?["endAni"]?.Value ?? string.Empty;
ai.Battle.isBattle = battleNode.Attributes?["isBattle"]?.Value == "true";
XmlNode? commentNode = battleNode.PreviousSibling;
while (includeComments && commentNode is XmlComment { Value: not null } comment) {
commentNode = commentNode.PreviousSibling;

if (comment.Value.Trim() == "전투") continue; // Redundant comment
ai.Battle.Insert(0, new Comment {
ai.Battle.Entries.Insert(0, new Comment {
Value = comment.Value,
});
}
ai.Battle.AddRange(ParseChildren(battleNode));
ai.Battle.Entries.AddRange(ParseChildren(battleNode));
}
XmlNode? battleEndNode = document.SelectSingleNode("npcAi/battleEnd");
if (battleEndNode != null) {
ai.BattleEnd.onlyDead = battleEndNode.Attributes?["onlyDead"]?.Value == "true";
XmlNode? commentNode = battleEndNode.PreviousSibling;
while (includeComments && commentNode is XmlComment { Value: not null } comment) {
commentNode = commentNode.PreviousSibling;
ai.BattleEnd.Insert(0, new Comment {
ai.BattleEnd.Entries.Insert(0, new Comment {
Value = comment.Value,
});
}
ai.BattleEnd.AddRange(ParseChildren(battleEndNode));
ai.BattleEnd.Entries.AddRange(ParseChildren(battleEndNode));
}
XmlNode? aiPresetsNode = document.SelectSingleNode("npcAi/aiPresets");
if (aiPresetsNode != null) {
Expand Down
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.5</PackageVersion>
<PackageVersion>2.4.6</PackageVersion>
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major | ⚡ Quick win

Patch bump is too small for this public API break.

NpcAi.Battle and NpcAi.BattleEnd no longer expose List<Entry>; they now expose new public container types. That is a breaking change for downstream callers, so publishing it as 2.4.6 hides incompatible API changes behind a patch update. Please either ship this as a major version or preserve the old shape for a deprecation cycle.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@Maple2.File.Parser/Maple2.File.Parser.csproj` at line 16, The package version
update is too small for the breaking change: either restore the previous public
types for NpcAi.Battle and NpcAi.BattleEnd (keep List<Entry> shape and add the
new container types as new APIs or provide adapter properties/methods) OR, if
you intend to keep the breaking change, bump the PackageVersion to a new major
(e.g., X.0.0) in the project file so the release is semantically major; modify
Maple2.File.Parser.csproj PackageVersion accordingly and ensure NpcAi.Battle and
NpcAi.BattleEnd are updated consistently with your chosen approach.

<TargetFramework>net8.0</TargetFramework>
<PackageReadmeFile>README.md</PackageReadmeFile>
<ImplicitUsings>enable</ImplicitUsings>
Expand Down
16 changes: 14 additions & 2 deletions Maple2.File.Parser/Xml/AI/NpcAi.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,19 @@
// ./data/server/ai/**/%s.xml
public class NpcAi {
public List<Entry> Reserved = new();
public List<Entry> Battle = new();
public List<Entry> BattleEnd = new();
public Battle Battle = new();
public BattleEnd BattleEnd = new();
public List<Entry> AiPresets = new();
}

public class Battle {
public string startAni = string.Empty;
public string endAni = string.Empty;
public bool isBattle;
public List<Entry> Entries = [];
}

public class BattleEnd {
public bool onlyDead;
public List<Entry> Entries = [];
}
8 changes: 4 additions & 4 deletions Maple2.File.Tests/AiParserTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,8 @@ public void TestAiParser() {
HashSet<string> definedPresets = new();

bool hasReserved = data.Reserved.Count > 0;
bool hasBattle = data.Battle.Count > 0;
bool hasBattleEnd = data.BattleEnd.Count > 0;
bool hasBattle = data.Battle.Entries.Count > 0;
bool hasBattleEnd = data.BattleEnd.Entries.Count > 0;
bool hasAiPresets = data.AiPresets.Count > 0;
bool hasAnyNodes = hasReserved || hasBattle || hasBattleEnd || hasAiPresets;
bool hasAnySubNodes = false;
Expand All @@ -81,13 +81,13 @@ public void TestAiParser() {
hasAnySubNodes = true;
}

foreach (Entry entry in data.Battle) {
foreach (Entry entry in data.Battle.Entries) {
TestEntry(entry, definedPresets);

hasAnySubNodes = true;
}

foreach (Entry entry in data.BattleEnd) {
foreach (Entry entry in data.BattleEnd.Entries) {
TestEntry(entry, definedPresets);

hasAnySubNodes = true;
Expand Down
Loading