Skip to content

libeq_wld: Support new-format (0x1000C800) WLD files - #55

Open
djhenry wants to merge 1 commit into
cjab:mainfrom
djhenry:fix/tolerant-zone-wld-parsing
Open

libeq_wld: Support new-format (0x1000C800) WLD files#55
djhenry wants to merge 1 commit into
cjab:mainfrom
djhenry:fix/tolerant-zone-wld-parsing

Conversation

@djhenry

@djhenry djhenry commented Jul 4, 2026

Copy link
Copy Markdown

Zone WLDs from Luclin onward use header version 0x1000C800, which changes the encoding of DmSpriteDef2 texture coordinates from 2x i16 to 2x f32. Reading them as i16 shifted every field after the coordinate block, so faces and material groups came out as garbage.

The format is now read from the file header, using the same check the client makes (version & 0xffff0000 == 0x10000000), and passed through to the fragment parser. DmSpriteDef2::texture_coordinates becomes an enum over the two encodings so a file still round-trips back to its original bytes. Mesh::texture_coordinates converts both to f32 as before, so callers see no difference.

Breaking change: DmSpriteDef2::texture_coordinates is now TextureCoordinates::Old(Vec<(i16, i16)>) or New(Vec<(f32, f32)>) rather than a plain Vec<(i16, i16)>, which also changes its serde representation.

Verified by parsing and re-serializing every WLD in a RoF2 install (1594 files across 1079 archives) with this branch and with main, and comparing the results. The 25 new-format zones now parse; output for the 1569 old-format files is byte for byte identical to main, including the 27 old-format _obj files that fail on both.

@anarelion

Copy link
Copy Markdown

I don't think anyone wants to review AI slop. There are way too many unnecessary changes that clutter the purpose of this PR.

@djhenry

djhenry commented Jul 27, 2026

Copy link
Copy Markdown
Author

I don't think anyone wants to review AI slop. There are way too many unnecessary changes that clutter the purpose of this PR.

Sorry about that. Let me see if I can clean it up.

@djhenry
djhenry force-pushed the fix/tolerant-zone-wld-parsing branch from 39fb132 to aaabf45 Compare July 27, 2026 22:24
@djhenry djhenry changed the title Support new-format (0x1000c800) zone WLDs and fix later-era parsing panics libeq_wld: Support new-format (0x1000C800) WLD files Jul 27, 2026
@djhenry
djhenry force-pushed the fix/tolerant-zone-wld-parsing branch from aaabf45 to af1c315 Compare July 27, 2026 22:41
Zone WLDs from Luclin onward use header version 0x1000C800, which changes
the encoding of DmSpriteDef2 texture coordinates from 2x i16 to 2x f32.
Reading them as i16 shifted every field after the coordinate block,
producing garbage faces and material groups.

The format is now read from the file header, using the same check the
client makes, and passed through to the fragment parser. Texture
coordinates become an enum over the two encodings so that a file can be
round-tripped back to its original bytes. Mesh::texture_coordinates
converts both to f32 as before, so callers see no difference.

Verified by parsing and re-serializing every WLD in a RoF2 install. The
25 new-format zones now parse; output for the 1569 old-format files is
byte for byte identical to before.
@djhenry
djhenry force-pushed the fix/tolerant-zone-wld-parsing branch from af1c315 to 86f4461 Compare July 27, 2026 23:02
@djhenry

djhenry commented Jul 27, 2026

Copy link
Copy Markdown
Author

PR has been de-slopped. Thanks for the feedback!

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.

2 participants