Repository navigation
feat(commandline): Add -dataDir option to load game data from a list of folders - #3534
CryoTheRenegade wants to merge 11 commits into
Conversation
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
|
Note Reviews pausedIt 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 Use the following commands to manage reviews:
Use the checkboxes below for quick actions:
No actionable comments were generated in the recent review. WalkthroughAdds the Zero Hour ChangesGenerals data directory override
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
Suggested reviewers: Merge Risk:
|
[Medium impact] The option changes archive selection in both games and in replay workers that use it. Fix the folder-name conversion before merging so replay workers can load the same archives as the parent. Findings
|
0be8de7 to
14a87c2
Compare
There was a problem hiding this comment.
Actionable comments posted: 1
ℹ️ Review info
⚙️ Run configuration
- Configuration used: Organization UI
- Review profile: CHILL
- Plan: Advanced
- Run ID:
2d209611-3d9c-4b2e-8826-53b5d90c5e78
📒 Files selected for processing: 3
Core/GameEngine/Source/Common/CommandLine.cppCore/GameEngine/Source/Common/System/BIGFileSystem.cppGeneralsMD/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.
|
Instead of |
I think it should be even more generic tbh, like how |
I could do this |
|
Changed to I left |
| // -dataDir "<dir1>;<dir2>" adds folders with lower priority .big files. | ||
| if (num > 1) | ||
| { | ||
| TheWritableGlobalData->m_dataDirs = args[1]; |
There was a problem hiding this comment.
If a user writes -dataDir "PathA" -dataDir "PathB" then PathA is erased.
There was a problem hiding this comment.
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. |
There was a problem hiding this comment.
Semicolon is a valid path character on Windows.
There was a problem hiding this comment.
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. |
There was a problem hiding this comment.
Any chance we can have multiple folders for m_modDir as well? Can be separate change.
There was a problem hiding this comment.
Agreed, I'll do that in a separate PR.
| AsciiString dataDir; | ||
| while (dataDirs.nextToken(&dataDir, ";")) | ||
| { | ||
| FileSystem::appendPathSeparator(dataDir); |
There was a problem hiding this comment.
Yes, the archive loader appends the file mask straight to the folder. It's in the parser now.
… 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>
dcef799 to
eb77fee
Compare
| // TheSuperHackers @feature CryoTheRenegade 17/10/2026 | ||
| // Load .big files from this folder after the game folder. Repeat it for more folders. Earlier folders take priority. | ||
| // In Zero Hour these folders replace the Generals InstallPath registry value. Relative paths are resolved from the working directory. | ||
| { "-dataDir", parseDataDir }, |
There was a problem hiding this comment.
Replay workers lose selected folders
With -dataDir <folder> -replay <file> -jobs 2, the parent loads the selected folders, but replay workers do not. Their command includes -useCwd and -replay without any -dataDir options. If the installation has no Generals registry entry, workers miss the required assets and cannot run the replay correctly.
Forward each selected folder to workers in the same order, with paths quoted correctly.
Knowledge Base Used: RTS engine core
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>
| for (std::vector<AsciiString>::const_iterator it = dataDirs.begin(); it != dataDirs.end(); ++it) | ||
| { | ||
| UnicodeString dataDir; | ||
| dataDir.translate(*it); |
There was a problem hiding this comment.
Workers lose non-English folders
dataDir.translate(*it) reads UTF-8, but m_dataDirs contains bytes from Windows' narrow __argv. If Windows uses CP1251, for example, Cyrillic folder names become different characters when sent through CreateProcessW. The parent can load the folder while replay workers cannot, leaving them without the selected archives.
Convert these arguments using the same code page as __argv, or preserve their original wide form.
Knowledge Base Used: RTS engine core
There was a problem hiding this comment.
The replay filename on main uses the same conversion, so I'll fix both in a separate PR
Zero Hour finds the original Generals data only through the
InstallPathregistry value, so an install without that registry entry can't load it (#2348). Since #3149 added-setCwdand 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).-dataDirfolder, and earlier folders win over later ones.-dataDiris a startup option because the game engine initializes the archive file system before it parses the engine-init options.BIGFileSystem::initlogs the skipped folders, not the startup parser.DebugInitruns 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-setCwdor-useCwdchose, whichever order the options appear in.-dataDirfolder had.bigfiles.-jobsget the same-dataDirfolders. Trailing backslashes are doubled before the closing quote, so the worker's command-line parser does not read\"as an escaped quote.-modis unchanged. Mod files override the game data, while-dataDirfolders rank below the game folder.Closes #2348
AI Assistance
Claude Opus 5.5 assisted in implementation of this change
Council review
Rounds: 2