Skip to content

feat(cli): Load save and replay files from absolute paths - #3152

Draft
bobtista wants to merge 10 commits into
TheSuperHackers:mainfrom
bobtista:bobtista/feature/load-external-save-replay-files
Draft

feat(cli): Load save and replay files from absolute paths#3152
bobtista wants to merge 10 commits into
TheSuperHackers:mainfrom
bobtista:bobtista/feature/load-external-save-replay-files

Conversation

@bobtista

@bobtista bobtista commented Aug 15, 2026

Copy link
Copy Markdown

-loadsave and -loadreplay resolve their argument inside the managed user Save and Replays directories, so a file anywhere else has to be copied in before it can be opened. That rules out launching the game directly for a .sav or .rep from an operating-system file handler.

Now an absolute path is opened in place while a relative name still resolves from its managed directory, so both forms keep working. FileSystem::isAbsolutePath classifies the argument - a drive root (C:\, C:/), a current-drive or UNC root (leading separator), or a POSIX root - and GameState::getSaveGamePathForRead returns the path untouched when it is absolute. Save writes and the save menu are unaffected; they continue to use the managed directory.

-loadreplay is added alongside the existing -replay so an externally supplied replay goes through normal Replay synchronization handling. Suppressing synchronization errors stays opt-in through -ignoreReplaySyncErrors rather than being implied by loading from a path.

Command-line saves and replays are now also validated and deferred until the client has initialized the shell, so a bad path reports cleanly instead of failing partway into startup.

Verified on Windows against a clean upstream data set, with a bogus path as a control so a pass
is distinguishable from "the game started anyway":

case result
control: bogus absolute path exits
Save from an absolute path outside the user directory loads
Save from an absolute path containing spaces (quoted) loads
Save from a UNC path (\\localhost\C$\...) loads
Relative Save filename loads from the managed directory
Replay from an absolute path outside the user directory loads and plays
Replay from an absolute path containing spaces (quoted) loads and plays
Relative Replay filename loads from the managed directory
Normal Replay synchronization reporting reports normally (InGame:C337AE46 Replay:7FB5DE80)

Paths containing spaces work when quoted, which is the form an operating-system file handler
passes. nextParam is quote-aware: a token beginning with " terminates on the next " rather
than on whitespace, so the spaces inside are preserved.

Todo:

  • Both games build (z_generals and g_generals, 1458/1458)
  • Absolute path classification covers drive roots, UNC and current-drive roots, and POSIX roots
  • Save and Replay paths outside the user data directory
  • Paths containing spaces
  • Windows drive and UNC paths
  • Relative Save and Replay filenames still resolve from the managed directories
  • Normal Replay synchronization reporting
  • macOS and Linux absolute paths
  • Restarting an externally loaded Replay
  • -ignoreReplaySyncErrors

@bobtista bobtista self-assigned this Aug 15, 2026
@bobtista bobtista added Enhancement Is new feature or request Saveload Is Saveload/Xfer related labels Aug 15, 2026
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 Saveload Is Saveload/Xfer related

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Allow -loadsave and -loadreplay to load files from any directory

1 participant