Skip to content

Handle MPQ maps without HM3W headers - #1258

Merged
Frotty merged 4 commits into
masterfrom
codex/mpq-map-header-fix
Aug 25, 2026
Merged

Handle MPQ maps without HM3W headers#1258
Frotty merged 4 commits into
masterfrom
codex/mpq-map-header-fix

Conversation

@Frotty

@Frotty Frotty commented Aug 25, 2026

Copy link
Copy Markdown
Member

Summary

  • Handle valid Warcraft III maps whose MPQ archive starts at byte 0 without an HM3W prefix.
  • Create a fresh map header when configuration needs to update such a map; MapHeader.writeToMapFile then inserts it before the archive.
  • Avoid parsing the map header when no header-related configuration changes are requested.
  • Add regression coverage for both cases.

Checks

  • .\gradlew.bat test --tests tests.wurstscript.tests.WurstBuildConfigTests --no-daemon — passed.
  • git diff --check — passed.

Known gaps

  • No full test-suite run; this is a focused map-header regression fix.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 73c59e40de

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

// so use a new header in that case; writeToMapFile will insert it before
// the archive.
MapHeader mapHeader = startsWithMpqArchive(targetMap)
? new MapHeader()

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Preserve the player count in a synthesized header

When a headerless map configures only buildMapData.name() and relies on the existing war3map.w3i player definitions, this constructs a header whose maximum-player count remains the MapHeader default of zero (the new test explicitly confirms that value). The inserted HM3W header consequently advertises a zero-player map instead of preserving its existing capacity; populate the synthesized header from the already-extracted W3I metadata before writing it.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Fixed in d54d514. Header synthesis now receives the existing W3I player count and preserves it when only map name configuration changes; the regression test asserts maxPlayersCount=3.

@Frotty

Frotty commented Aug 25, 2026

Copy link
Copy Markdown
Member Author

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: d54d514371

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

// the archive.
boolean hasNoMapHeader = startsWithMpqArchive(targetMap);
MapHeader mapHeader = hasNoMapHeader
? new MapHeader()

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Preserve the map name in synthesized headers

When a headerless map configures buildMapData.players() but leaves buildMapData.name() blank, this creates a MapHeader with its default map-name field and writes it in front of the archive. The resulting HM3W header therefore no longer advertises the existing name stored in war3map.w3i; pass the W3I map name into this method and populate it when synthesizing the header, analogous to the preserved player count.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Fixed in 659e909. Header synthesis now receives the existing W3I map name and preserves it when player configuration changes without an explicit map name; the regression test covers that case.

@Frotty

Frotty commented Aug 25, 2026

Copy link
Copy Markdown
Member Author

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 659e9091ba

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +372 to +374
MapHeader mapHeader = hasNoMapHeader
? new MapHeader()
: MapHeader.ofFile(targetMap);

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Preserve W3I flags in synthesized headers

For a headerless MPQ whose W3I has nonzero map flags, such as fixed/custom forces or minimap settings, new MapHeader() leaves the header flags at their default while only the map name and player count are restored before writing. The synthesized HM3W metadata therefore disagrees with war3map.w3i, so clients that inspect the header can treat those flags as unset; pass the existing W3I flags into this path and copy them into the new header.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Fixed in 7c10423. Header synthesis now copies the existing W3I flags via getFlags().toInt(), with regression coverage asserting the flags survive insertion.

@Frotty

Frotty commented Aug 25, 2026

Copy link
Copy Markdown
Member Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Can't wait for the next one!

Reviewed commit: 7c1042339c

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@Frotty

Frotty commented Aug 25, 2026

Copy link
Copy Markdown
Member Author

Codex review loop complete: 4 review rounds on successive heads. Fixed the reported P2s by preserving W3I player count, map name, and flags when synthesizing an HM3W header for a headerless MPQ. Focused WurstBuildConfigTests pass, GitHub CI is green on Ubuntu and Windows, and the latest Codex review of 7c10423 found no major issues. Ready to merge.

@Frotty
Frotty merged commit 9eec8a8 into master Aug 25, 2026
6 checks passed
@Frotty
Frotty deleted the codex/mpq-map-header-fix branch August 25, 2026 18:45
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