Skip to content

Let ServerTableParser read XML from any source, not only an archive - #102

Closed
Zintixx wants to merge 1 commit into
masterfrom
xml-file-source
Closed

Zintixx wants to merge 1 commit into
masterfrom
xml-file-source

Conversation

@Zintixx

@Zintixx Zintixx commented Nov 29, 2026 •

Copy link
Copy Markdown

ServerTableParser could only read from a packed Server.m2d. This adds a two-method IXmlSource interface, which M2dReader implements, and XmlDirectorySource, which reads an unpacked folder laid out like the archive. A server can then parse edited XML without repacking, or serve the files from a source of its own, such as a database.

Changes

  • Maple2.File.IO/IXmlSource.cs: new. GetString(path) and GetXmlReader(path), with archive-relative paths such as table/Server/constants.xml. These are the only two reads ServerTableParser makes.
  • Maple2.File.IO/M2dReader.cs: implements IXmlSource explicitly through GetEntry, so its public API stays as it was.
  • Maple2.File.IO/XmlDirectorySource.cs: new. It strips the BOM like M2dReader.GetString, and reads into memory before creating the XmlReader, because parsers never dispose the reader. It refuses paths that resolve outside its root.
  • Maple2.File.Parser/ServerTableParser.cs: takes an IXmlSource. Its 65 xmlReader.X(xmlReader.GetEntry(path)) calls become xmlReader.X(path), and nothing else changes. new ServerTableParser(m2dReader) still compiles.
  • Maple2.File.Parser/Maple2.File.Parser.csproj: 2.4.41 to 2.4.42.
  • Maple2.File.Tests/XmlDirectorySourceTest.cs: new. These tests need no game data. ParseConstants is checked against a fixture folder, along with BOM stripping, missing files, a missing root, and paths that escape the root, including a sibling folder whose name starts with the root's.

Verification

  • XmlDirectorySourceTest and DataFreeParsingTest: 15 passed.
  • ServerTableParserTest against a real Server.m2d, read through M2dReader as an IXmlSource: 52 passed.
  • A downstream emulator built and passed its tests against a local pack of this branch, with its ServerTableMapper taking an IXmlSource.

🤖 Generated with Claude Code


Open in [code]smith · Need help on this PR? Tag @codesmith-bot with what you need.

Add IXmlSource, which M2dReader implements, and XmlDirectorySource, which reads an unpacked
folder laid out like the archive. ServerTableParser takes an IXmlSource, so existing M2dReader
callers compile unchanged. Bump to 2.4.42.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@coderabbitai

coderabbitai Bot commented Nov 29, 2026

Copy link
Copy Markdown

Important

  • Trigger review

This repository does not receive automatic reviews because it has fewer than 10 stars.

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 31488baa-3eee-4930-9387-ef3385b5ba15
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

@Zintixx

Zintixx commented Nov 29, 2026

Copy link
Copy Markdown
Author

Not needed after all: the server tables will be read from the XML once with the existing parser, then live in a database. Closing.

@Zintixx Zintixx closed this Nov 29, 2026
@Zintixx
Zintixx deleted the xml-file-source branch November 29, 2026 04:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant