Skip to content

feat(commandline): Add -dataDir option to load game data from a list of folders - #3534

Open
CryoTheRenegade wants to merge 14 commits into
TheSuperHackers:mainfrom
CryoTheRenegade:t3code/add-game-data-path-flag
Open

CryoTheRenegade wants to merge 14 commits into
TheSuperHackers:mainfrom
CryoTheRenegade:t3code/add-game-data-path-flag

Conversation

@CryoTheRenegade

@CryoTheRenegade CryoTheRenegade commented Oct 15, 2026 •

Copy link
Copy Markdown

Zero Hour finds the original Generals data only through the InstallPath registry value, so an install without that registry entry can't load it (#2348). Since #3149 added -setCwd and Miles and Bink load at runtime, Zero Hour can start from any folder, but it still needs that registry value to find the Generals data. -dataDir "<dir>" names a folder to load data from instead. Repeat it to add more folders. Multiple folders follow tintinhamans' review suggestion; they are separate options rather than a ; list because ; is a valid path character (xezon's review).

generalszh.exe -setCwd "D:\Games\ZeroHour" -dataDir "D:\Games\Generals"
 CommandLine::parseCommandLineForStartup
   parse -setCwd and -useCwd
+  for each non-empty -dataDir: append a path separator if missing, add it to GlobalData::m_dataDirs
   apply the final working directory

 BIGFileSystem::init
   load *.big from the working directory
+  for each folder in m_dataDirs, in order:
+    load *.big from it
+    if it had no .big files, log it and skip it
   (Zero Hour only)
-  read installPath from the registry
-  load *.big from installPath
+  if no -dataDir folder had .big files:
+    read installPath from the registry
+    load *.big from installPath

 ReplaySimulation::simulateReplaysInWorkerProcesses
   start each worker with -useCwd -replay "<file>"
+  and one -dataDir "<dir>" per folder in m_dataDirs
  • Files already in the archive tree are kept, so the game folder wins over every -dataDir folder, and earlier folders win over later ones.
  • -dataDir is a startup option because the game engine initializes the archive file system before it parses the engine-init options.
  • BIGFileSystem::init logs the skipped folders, not the startup parser. DebugInit runs that parser before it opens the log file, so a message logged there is lost. The working directory is final by then, so relative paths resolve against the folder that -setCwd or -useCwd chose, whichever order the options appear in.
  • The option works in both games. Only Zero Hour reads the registry, and only when no -dataDir folder had .big files.
  • Replay workers started by -jobs get the same -dataDir folders. Trailing backslashes are doubled before the closing quote, so the worker's command-line parser does not read \" as an escaped quote.
  • -mod is unchanged. Mod files override the game data, while -dataDir folders rank below the game folder.

Closes #2348

AI Assistance

Claude Opus 5.5 assisted in implementation of this change

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ⚠️ Failed 2026-10-15T20:26:19.637014Z 0be8de7 PR opened
ℹ️ 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" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.
To continue using code reviews, you can upgrade your account or add credits to your account and enable them for code reviews in your settings.

@coderabbitai

coderabbitai Bot commented Oct 15, 2026 •

Copy link
Copy Markdown

Review in Change Stack →

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review

No actionable comments were generated in the recent review.

Walkthrough

Adds the Zero Hour -genDataDir startup option. The parser stores the supplied path and adds a trailing separator when needed. BIG file system initialization uses the override when it identifies a directory. Otherwise, it reads the registry InstallPath.

Changes

Generals data directory override

Layer / File(s) Summary
Parse the directory override
GeneralsMD/Code/GameEngine/Include/Common/GlobalData.h, Core/GameEngine/Source/Common/CommandLine.cpp
GlobalData stores the directory override. The Zero Hour parser registers and parses -genDataDir and adds a trailing backslash when needed.
Use the override for BIG file discovery
Core/GameEngine/Source/Common/System/BIGFileSystem.cpp
BIG file system initialization uses the override when it identifies a directory. If the override is empty or invalid, initialization reads the registry InstallPath.

Estimated code review effort: 2 (Simple) | ~10 minutes

Change: Feature

Sequence Diagram(s)

sequenceDiagram
  participant CommandLineParser
  participant GlobalData
  participant BIGFileSystem
  participant Registry
  CommandLineParser->>GlobalData: Store -genDataDir value
  BIGFileSystem->>GlobalData: Read m_generalsDataDir
  BIGFileSystem->>Registry: Read InstallPath when override is empty or invalid
Loading

Suggested reviewers: caball009

Merge Risk: Low · previous review 59fe7

The directory override works for a supplied path. If its value is omitted before -useCwd, that option is skipped and the game may use the executable directory and registry fallback instead. This bounded case does not block merging.

Pre-merge checks: Passed 3 · Failed 1

Failed Failed checks: 1 warning

Check name Status Explanation Resolution
Title check Warning The title describes a -dataDir option that is not present in the changes. The implementation adds the Zero Hour-only -genDataDir option for the Generals data directory. Update the title to identify the implemented option, for example: feat(commandline): Add -genDataDir option for Generals data.
Passed Passed checks: 3 passed

Check name Status Explanation
Linked Issues check Passed Issue #2348 requires Zero Hour to find the original Generals BIG files without requiring a registry entry. The Zero Hour-only -genDataDir parser stores the selected path in `GlobalData::m_generalsDa…
Out of Scope Changes check Passed The changes stay within issue #2348. They add the Zero Hour startup option, store its value, validate the directory, load Generals archives, and retain registry fallback for compatibility. The `Global…
Description check Passed The description explains the change: a Zero Hour startup option that sets a Generals data directory, the registry fallback in BIGFileSystem::init, and the related replay-worker and working-directory b…
Full details: Linked Issues check

Explanation

Issue #2348 requires Zero Hour to find the original Generals BIG files without requiring a registry entry. The Zero Hour-only -genDataDir parser stores the selected path in GlobalData::m_generalsDataDir. BIGFileSystem::init validates that path and loads *.big files from it. The previous non-empty registry-path assertion is removed. Registry lookup remains only as a fallback when the option is absent or invalid. The change also preserves the existing working-directory behavior for relative paths. No separate coding requirement is stated for automated tests.

Full details: Out of Scope Changes check

Explanation

The changes stay within issue #2348. They add the Zero Hour startup option, store its value, validate the directory, load Generals archives, and retain registry fallback for compatibility. The GlobalData field and parser comments directly support this behavior. No unrelated product behavior is changed.

Full details: Description check

Explanation

The description explains the change: a Zero Hour startup option that sets a Generals data directory, the registry fallback in BIGFileSystem::init, and the related replay-worker and working-directory behavior. It is specific and relevant to the changeset, so it is not off-topic or vague.

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

ℹ️ Recent review info

⚙️ Run configuration

  • Configuration used: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 4785d468-8e18-4c1d-8b45-2cd692558cad
📥 Commits

Reviewing files that changed from the base of the PR and between 80f1967 and 59fe76b.

📒 Files selected for processing: 2

  • Core/GameEngine/Source/Common/CommandLine.cpp
  • Core/GameEngine/Source/Common/System/BIGFileSystem.cpp
💤 Files with no reviewable changes: 1

  • Core/GameEngine/Source/Common/CommandLine.cpp

Included review availability: This review used your included allowance. Your plan provides up to 4 included reviews per hour; 3 remain after this review.

@greptile-apps

greptile-apps Bot commented Oct 15, 2026 •

Copy link
Copy Markdown

RetriggerView in GreptileConfidence Score: 5/5

[Medium impact] The PR appears safe to merge with no new actionable issues found.

Summary

Adds repeatable -dataDir options to load extra game archives below the working folder’s priority.

  • The game loads extra .big files from ordered data folders.
  • Parallel replay workers receive the same data folders as the game.

Diagram

%%{init: {'theme': 'neutral'}}%%
flowchart TD
    A[Read startup options] --> B[Choose working folder]
    B --> C[Load working-folder archives]
    C --> D[Load dataDir folders in order]
    D --> E{Zero Hour and no dataDir archive loaded?}
    E -- Yes --> F[Load Generals registry folder]
    E -- No --> G[Continue startup]
    F --> G
    G --> H[Load mods with higher priority]
    G --> I[Forward dataDir folders to replay workers]
Loading

Reviews (11) · Last reviewed commit: "Use ensureTrailingPathSeparatorInPath af..." · Reviewed by Greptile

@CryoTheRenegade
CryoTheRenegade force-pushed the t3code/add-game-data-path-flag branch from 0be8de7 to 14a87c2 Compare October 15, 2026 20:29

@coderabbitai coderabbitai 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.

Actionable comments posted: 1


ℹ️ Review info
⚙️ Run configuration
  • Configuration used: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 2d209611-3d9c-4b2e-8826-53b5d90c5e78
📥 Commits

Reviewing files that changed from the base of the PR and between 0af9db4 and 14a87c2.

📒 Files selected for processing: 3
  • Core/GameEngine/Source/Common/CommandLine.cpp
  • Core/GameEngine/Source/Common/System/BIGFileSystem.cpp
  • GeneralsMD/Code/GameEngine/Include/Common/GlobalData.h

Included review availability: This review used your included allowance. Your plan provides up to 4 included reviews per hour; 3 remain after this review.

@xezon

xezon commented Oct 17, 2026

Copy link
Copy Markdown

Instead of genDataDir, it may be better to make it more generic with baseGameDir or dependentGameDir

@tintinhamans

tintinhamans commented Oct 17, 2026 •

Copy link
Copy Markdown

Instead of genDataDir, it may be better to make it more generic with baseGameDir or dependentGameDir

I think it should be even more generic tbh, like how PATH works. Just have -dataDir "<directory_1>;<directory_2>". That way we can maybe even replace the need for -mod.

@CryoTheRenegade

Copy link
Copy Markdown
Author

Instead of genDataDir, it may be better to make it more generic with baseGameDir or dependentGameDir

I think it should be even more generic tbh, like how PATH works. Just have -dataDir "<directory_1>;<directory_2>". That way we can maybe even replace the need for -mod.

I could do this

@CryoTheRenegade CryoTheRenegade changed the title feat(commandline): Add -genDataDir option to locate the Generals data without the registry feat(commandline): Add -dataDir option to load game data from a list of folders Oct 17, 2026
@CryoTheRenegade

Copy link
Copy Markdown
Author

Changed to -dataDir "<dir1>;<dir2>". It works in both games and loads each folder's .big files after the game folder, in the listed order, so earlier folders take priority. In Zero Hour the folders replace the Generals registry lookup, and the registry is still used if none of the folders exists.

I left -mod alone. Mod files override the game data, while -dataDir folders rank below the game folder, so merging the two needs a way to give each folder a priority. That fits better in a follow-up.

// -dataDir "<dir1>;<dir2>" adds folders with lower priority .big files.
if (num > 1)
{
TheWritableGlobalData->m_dataDirs = args[1];

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

If a user writes -dataDir "PathA" -dataDir "PathB" then PathA is erased.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Each -dataDir now adds one folder, so repeating it keeps all of them.

{ "-useCwd", parseUseCwd },

// TheSuperHackers @feature CryoTheRenegade 17/10/2026
// Load .big files from these ';'-separated folders after the game folder. Earlier folders take priority.

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Semicolon is a valid path character on Windows.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Done. It's one folder per -dataDir now, so there's no ; list.


loadArchiveFilesFromDirectory("", "*.big");

// TheSuperHackers @feature CryoTheRenegade 17/10/2026 Load the -dataDir folders in the listed order.

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Any chance we can have multiple folders for m_modDir as well? Can be separate change.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Agreed, I'll do that in a separate PR.

AsciiString dataDir;
while (dataDirs.nextToken(&dataDir, ";"))
{
FileSystem::appendPathSeparator(dataDir);

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Is this required?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Yes, the archive loader appends the file mask straight to the folder. It's in the parser now.

@xezon xezon added Enhancement Is new feature or request Minor Severity: Minor < Major < Critical < Blocker Gen Relates to Generals ZH Relates to Zero Hour System Is Systems related labels Nov 15, 2026
CryoTheRenegade and others added 7 commits November 16, 2026 20:37
… without the registry

Zero Hour loads the original Generals .big files from the Generals InstallPath
registry value. -genDataDir "<path>" overrides it so the game can run from any
folder together with -setCwd. Invalid directories fall back to the registry.
…ls data without the registry

feat(commandline): Add -genDataDir option to locate the Generals data without the registry

Zero Hour loads the original Generals .big files from the Generals InstallPath
registry value. -genDataDir "<path>" overrides it so the game can run from any
folder together with -setCwd. Invalid directories fall back to the registry.
…install path in Zero Hour

Zero Hour can find the Generals files without the registry, for example in the
ZH_Generals folder of the Steam install.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…log opens

DebugInit runs the startup command line parser before it opens the log file,
so the "is not a directory" message never reached the log. BIGFileSystem::init
now checks the folder. The working directory is final by then, so relative
paths still resolve against the -setCwd or -useCwd folder.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
-dataDir "<dir1>;<dir2>" loads the .big files of each folder after the game
folder, in the listed order. Files already loaded are kept, so earlier folders
take priority. Folders that do not exist are logged and skipped. The option
works in both games. In Zero Hour the folders replace the Generals InstallPath
registry value; if none of them exists, the registry is used as before.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ir folders

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A ';' list cannot hold folders whose names contain ';', and a second
-dataDir replaced the first one. Each -dataDir now adds one folder, and
the path separator is appended when the option is parsed.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
An empty -dataDir reloaded the game folder, which counted as a loaded
data folder and made Zero Hour skip the Generals registry folder. The
old ';' tokenizer skipped empty entries.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@CryoTheRenegade
CryoTheRenegade force-pushed the t3code/add-game-data-path-flag branch from dcef799 to eb77fee Compare November 17, 2026 03:39
CryoTheRenegade and others added 3 commits November 16, 2026 20:51
Workers started by -jobs only got -useCwd and -replay, so in Zero Hour
without a Generals registry entry they missed the Generals archives.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…nly flag as maybe unused

Generals never reads loadedDataDir, so Clang warns that it is set but not used.

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

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
CryoTheRenegade and others added 3 commits November 24, 2026 11:01
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…kers#3694

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Enhancement Is new feature or request Gen Relates to Generals Minor Severity: Minor < Major < Critical < Blocker System Is Systems related ZH Relates to Zero Hour

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Change assertion about missing Generals files for Zero Hour

5 participants