Skip to content

fix: support VDF archives larger than 2 GiB - #130

Open
FadedAtlas wants to merge 2 commits into
GothicKit:mainfrom
FadedAtlas:main
Open

fix: support VDF archives larger than 2 GiB#130
FadedAtlas wants to merge 2 commits into
GothicKit:mainfrom
FadedAtlas:main

Conversation

@FadedAtlas

Copy link
Copy Markdown

Problem

VDF archives >= 2 GiB fail to load on Windows (MinGW), reporting an empty signature.
The read fails outright, so the buffer stays zeroed and the parser sees null bytes where the signature should be.

Two bugs chain together
The Win32 mmap check fails to compile on GCC 14+:
CreateFile + wide literal = CreateFileA, silently leaving _ZK_WITH_MMAP undefined.
The resulting std::ifstream fallback then issues one read() of the whole file, which under MinGW fails outright above INT32_MAX (2,147,483,647) returning gcount=0.

Changes

  • support/BuildSupport.cmake: CreateFile -> CreateFileW, matching
    MmapWin32.cc. Re-enables memory mapping on MinGW.
  • src/Vfs.cc: read VDF file in chunks.

Result

"Vurt's Gothic II Graphics Overhaul.vdf" (2.39 GB) now mounts correctly.

Questions you may ask

  1. Why didn't CI catch this?
    • ZenKit's Windows job builds with MSVC, where the mismatch is only a warning. OpenGothic compiles ZenKit with MinGW, so its releases hit both bugs.
  2. Why 256 MB chunks?
    • 256 MB sits an order of magnitude below every known limit. 1 GB would work equally well.

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