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.17</PackageVersion>
<PackageVersion>2.4.18</PackageVersion>
<TargetFramework>net8.0</TargetFramework>
<PackageReadmeFile>README.md</PackageReadmeFile>
<ImplicitUsings>enable</ImplicitUsings>
Expand Down
74 changes: 74 additions & 0 deletions Maple2.File.Parser/Xml/Map/MapXBlock.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
using System.Numerics;
using System.Xml.Serialization;
using M2dXmlGenerator;

namespace Maple2.File.Parser.Xml.Map;

// ./data/xml/mapxblock/<xblockname>.xml
[XmlRoot("ms2")]
public class MapXBlockDataRoot {
[XmlElement] public ClientProperty clientProperty;
[XmlElement] public Minimap minimap;
[XmlElement] public Fog fog;
[XmlElement] public HeightFog heightfog;
}

public class ClientProperty {
[XmlAttribute] public string bgDay;
}

public partial class Minimap {
[XmlElement] public Image image;
[XmlElement] public Frustum frustum;
[XmlElement] public Screen screen;
[XmlElement] public Camera camera;
[XmlElement] public Edit edit;

public class Image {
[XmlAttribute] public string name;
[XmlAttribute] public float left;
[XmlAttribute] public float right;
[XmlAttribute] public float top;
[XmlAttribute] public float bottom;
[XmlAttribute] public string icon;
}

public class Frustum {
[XmlAttribute] public float left;
[XmlAttribute] public float right;
[XmlAttribute] public float top;
[XmlAttribute] public float bottom;
[XmlAttribute] public float near;
[XmlAttribute] public float far;
[XmlAttribute] public bool ortho;
}

public class Screen {
[XmlAttribute] public float left;
[XmlAttribute] public float right;
[XmlAttribute] public float top;
[XmlAttribute] public float bottom;
}

public partial class Camera {
[M2dVector3] public Vector3 position;
[M2dVector3] public Vector3 rotation;
Comment on lines +54 to +55

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🎯 Functional Correctness | 🟠 Major | ⚡ Quick win

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
set -euo pipefail

echo "== files =="
git ls-files | rg '(^|/)MapXBlock\.cs$|(^|/)XmlVector3Generator\.cs$|XBlockParser|Xml' || true

echo "== candidate file sizes =="
for f in $(git ls-files | rg '(^|/)MapXBlock\.cs$|(^|/)XmlVector3Generator\.cs$'); do
  stat -c '%n %s bytes' "$f"
done

echo "== outlines =="
for f in $(git ls-files | rg '(^|/)MapXBlock\.cs$|(^|/)XmlVector3Generator\.cs$'); do
  echo "--- $f ---"
  ast-grep outline "$f" || true
done

echo "== MapXBlock excerpt =="
f=$(git ls-files | rg '(^|/)MapXBlock\.cs$' | head -n1)
if [ -n "${f:-}" ]; then
  nl -ba "$f" | sed -n '1,120p'
fi

echo "== XmlVector3Generator excerpt =="
g=$(git ls-files | rg '(^|/)XmlVector3Generator\.cs$' | head -n1)
if [ -n "${g:-}" ]; then
  nl -ba "$g" | sed -n '1,240p'
fi

Repository: MS2Community/Maple2.File

Length of output: 18515


🏁 Script executed:

#!/bin/bash
set -euo pipefail

echo "== MapXBlock excerpt =="
f=$(git ls-files | rg '(^|/)MapXBlock\.cs$' | head -n1)
if [ -n "${f:-}" ]; then
  nl -ba "$f" | sed -n '1,140p'
fi

echo "== XmlVector3Generator excerpt =="
g=$(git ls-files | rg '(^|/)XmlVector3Generator\.cs$' | head -n1)
if [ -n "${g:-}" ]; then
  nl -ba "$g" | sed -n '1,260p'
fi

echo "== XBlockParser relevant excerpts =="
p=$(git ls-files | rg '(^|/)XBlockParser\.cs$' | head -n1)
if [ -n "${p:-}" ]; then
  nl -ba "$p" | sed -n '1,220p'
fi

echo "== culture-sensitive parse/format behavior with fr-FR =="
python3 - <<'PY'
from decimal import Decimal, DecimalContextError

values = ["123.45", "123,456"]
for v in values:
    for locale_decimal in [".", ","]:
        # Simulate C# float.Split(' ') + decimal.Parse(string, currentCulture)
        # when currentCulture DecimalSeparator == "."
        if locale_decimal == ".":
            try:
                parsed = float(v.replace(",", "."))
            except ValueError as e:
                parsed = f"parse-fail-{type(e).__name__}"
        else:
            try:
                parsed = float(v.replace(",", "."))
            except ValueError as e:
                parsed = f"parse-fail-{type(e).__name__}"
        print(f"value={v}, locale_decimal={locale_decimal!r}, parsed={parsed}")
PY

echo "== behavioral probe of C# culture parsing in Python? only locale examples maybe sufficient =="

Repository: MS2Community/Maple2.File

Length of output: 226


🏁 Script executed:

#!/bin/env sh
set -euo pipefail

awk '{ printf "%6d\t%s\n", NR, $0 }' Maple2.File.Parser/Xml/Map/MapXBlock.cs | sed -n '1,140p'

awk '{ printf "%6d\t%s\n", NR, $0 }' Maple2.File.Generator/XmlVector3Generator.cs | sed -n '1,260p'

awk '{ printf "%6d\t%s\n", NR, $0 }' Maple2.File.Parser/MapXBlock/XBlockParser.cs | sed -n '1,240p'

awk '{ printf "%6d\t%s\n", NR, $0 }' Maple2.File.Parser/MapXBlock/XBlockParserTest.cs | sed -n '1,400p'

Repository: MS2Community/Maple2.File

Length of output: 15378


Make generated Vector3 XML serialization culture-invariant.

MapXBlockCamera.position and camera.rotation use M2dVector3, which emits X,Y,Z and parses components with float.Parse without an invariant provider. In a culture where , is the decimal separator, serialized values can split/misparse or reject valid xblock XML. Update XmlVector3Generator to use invariant formatting/parsing and add a regression test under such a culture.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@Maple2.File.Parser/Xml/Map/MapXBlock.cs` around lines 54 - 55, Update
XmlVector3Generator so M2dVector3 serialization formats all Vector3 components
with invariant culture and parsing uses the same invariant provider. Preserve
the X,Y,Z representation used by MapXBlockCamera.position and camera.rotation,
and add a regression test that exercises round-trip XML serialization/parsing
under a culture using comma decimal separators.

}

public class Edit {
[XmlAttribute] public float zoomfactor;
}
}

public partial class Fog {
[M2dColor] public System.Drawing.Color color;
[XmlAttribute] public float near;
[XmlAttribute] public float far;
}

public partial class HeightFog {
[M2dColor] public System.Drawing.Color color;
[XmlAttribute] public float upper;
[XmlAttribute] public float lower;
[XmlAttribute] public int percentage;
}
1 change: 1 addition & 0 deletions Maple2.File.Parser/Xml/Table/Server/ItemOptionRandom.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ public class ItemOptionRandomRoot {

public class ItemOptionRandom {
[XmlAttribute] public int code;
[XmlAttribute] public int grade; // custom
[XmlAttribute] public int statGroup;
[XmlAttribute] public int levelGroupID;
[XmlAttribute] public int pickCount;
Expand Down
Loading