Skip to content

fix(wwlib): address CODEX review findings for PR #105 (SDL3 backends)#107

Closed
Dadud wants to merge 15 commits intow3dhub:mainfrom
Dadud:pr-105-fixes
Closed

fix(wwlib): address CODEX review findings for PR #105 (SDL3 backends)#107
Dadud wants to merge 15 commits intow3dhub:mainfrom
Dadud:pr-105-fixes

Conversation

@Dadud
Copy link
Copy Markdown

@Dadud Dadud commented Apr 22, 2026

Fixes three CODEX review findings that block PR #105 (Add non-Windows backends to a few classes).

Fixes

High — rawfile.cpp READ|WRITE data loss

The SDL3 READ|WRITE path used 'r+' fallback to 'w+', which truncates existing files (silent data loss for callers like tagblock.cpp that open READ|WRITE then read back a header). Fixed by using 'r+b' then 'w+b', matching OPEN_ALWAYS semantics.

Medium — verchk.cpp FAT date month decode wrong

Month field mask was 0xf (4 bits) but FAT month is 5 bits (bits 5-8 of FAT date). Corrected to 0x1f.

Medium — rcfile.cpp static init order (cross-TU)

The extern std::unordered_map Static_Resources declared in rcfile.h and defined in a CMake-generated TU had undefined static init order. Replaced with a function-local static (Meyers singleton) via inline GetStaticResources(), guaranteeing construction on first use.

Files changed

  • Code/wwlib/rawfile.cpp — READ|WRITE SDL3 fix
  • Code/wwlib/verchk.cpp — FAT date decode fix
  • Code/wwlib/rcfile.h — extern → lazy-init accessor
  • Code/wwlib/rcfile.cpp — use GetStaticResources()
  • Code/Commando/renegade_resources.cpp — generated file updated
  • cmake/embed.py — generator updated for future runs

madebr and others added 15 commits March 25, 2026 21:01
NOTE: This class is not used by the main game, and can be removed there.
This partially reverts bab59cf9d4238a9821592e9a74dcedd1fc31a229
This fixes a bug introduced by 60aa437
High: rawfile.cpp READ|WRITE path no longer truncates existing files.
  - Changed SDL3 path from 'r+' fallback to 'r+b' then 'w+b', matching
    OPEN_ALWAYS semantics (preserve existing file, create if absent).

Medium: verchk.cpp FAT date month field decode corrected.
  - Mask was 0xf (4 bits), should be 0x1f (5 bits) for FAT month field.

Medium: rcfile.cpp static init order fix (cross-TU).
  - Replaced 'extern std::unordered_map Static_Resources' with an inline
    function GetStaticResources() using a function-local static (Meyers
    singleton), guaranteeing construction on first use.
  - cmake/embed.py generator updated.
@Dadud Dadud closed this Apr 22, 2026
@Dadud Dadud deleted the pr-105-fixes branch April 23, 2026 03:26
Dadud pushed a commit to Dadud/OpenW3D that referenced this pull request Apr 23, 2026
Resolves 4 merge conflicts:
- buildnum.cpp/h: replaced old BuildNumber[char] post-build stamping with git-embedded info
- dlgmainmenu.cpp: updated Update_Version_Number to use git info format
- ConsoleMode.cpp: removed Get_Version_Number call (no longer needed)

PR w3dhub#107 fixes applied on top:
- rawfile.cpp: READ|WRITE data loss fix (r+b then w+b)
- verchk.cpp: FAT date month decode (0xf → 0x1f)
- rcfile: static init order fix (Meyers singleton)
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