Skip to content

feat(cli): Add -loadsave option#3001

Open
bobtista wants to merge 4 commits into
TheSuperHackers:mainfrom
bobtista:bobtista/feat/loadsave-commandline
Open

feat(cli): Add -loadsave option#3001
bobtista wants to merge 4 commits into
TheSuperHackers:mainfrom
bobtista:bobtista/feat/loadsave-commandline

Conversation

@bobtista

@bobtista bobtista commented Jul 22, 2026

Copy link
Copy Markdown

Fixes #2999
Merge after #2998

There is no command-line option for loading a save during startup. Also, in headless mode, particle and ghost dummy implementations also consume less data than their rendered implementations, while terrain visual state is only partially initialized.

Now -loadsave loads a save from the user Save directory during startup in normal or headless mode.

Renderer-owned particle, terrain visual and ghost-object blocks are omitted from headless saves and skipped when loading rendered saves headlessly.

Todo:

[x] Test normal save loaded normally
[x] Test normal save loaded headlessly
[x] Test headless save loaded normally
[x] Test headless save loaded headlessly
[x] Replicate to Generals

Notes:
When using debug build, if the save file is not found, there's a "File not found" error, then it exits cleanly. In windowed, m_shellMapOn gets set false, so the menu works normally but the shellmap stops.

@bobtista bobtista self-assigned this Jul 22, 2026
@bobtista bobtista added the Enhancement Is new feature or request label Jul 22, 2026
@greptile-apps

greptile-apps Bot commented Jul 22, 2026

Copy link
Copy Markdown

Greptile Summary

Adds command-line save loading and makes save serialization compatible across rendered and headless modes.

  • Registers -loadsave <filename> and loads the selected user save during engine startup.
  • Omits renderer-owned particle, terrain-visual, and ghost-object blocks from headless saves and skips them when loading rendered saves headlessly.
  • Centralizes Zero Hour save/load feedback and updates the relevant GUI load paths.
  • Suppresses shell, shell-map, and intro startup behavior while command-line save loading is pending.

Confidence Score: 5/5

The PR appears safe to merge because no eligible blocking failure remains from the displayed follow-up review context.

No blocking failure remains.

Important Files Changed

Filename Overview
Generals/Code/GameEngine/Source/Common/GameEngine.cpp Adds the base-game startup path that prepares and loads a command-line-selected save before entering the main loop.
GeneralsMD/Code/GameEngine/Source/Common/GameEngine.cpp Adds the equivalent Zero Hour startup save-loading path.
Generals/Code/GameEngine/Source/Common/System/SaveGame/GameState.cpp Excludes renderer-owned snapshot blocks when saving or loading in base-game headless mode.
GeneralsMD/Code/GameEngine/Source/Common/System/SaveGame/GameState.cpp Updates Zero Hour save result handling and headless snapshot-block serialization.
GeneralsMD/Code/GameEngine/Source/GameClient/GUI/GUICallbacks/SaveLoadFeedback.cpp Introduces shared UI feedback handling for Zero Hour save and load result codes.
GeneralsMD/Code/GameEngine/Source/GameClient/GUI/GUICallbacks/Menus/PopupSaveLoad.cpp Routes save/load menu result handling through the shared feedback implementation.
GeneralsMD/Code/GameEngine/Source/GameClient/GUI/Shell/Shell.cpp Prevents shell and shell-map startup while a command-line save load is pending.

Sequence Diagram

sequenceDiagram
  participant CLI as Command line
  participant Engine as GameEngine
  participant State as GameState
  participant Logic as GameLogic
  participant Shell as Shell

  CLI->>Engine: Set -loadsave filename
  Engine->>State: Read save metadata
  Engine->>Logic: Prepare single-player game
  Engine->>State: Load save
  alt Load succeeds
    Engine->>Shell: Hide shell
    Engine->>Engine: Enter main loop
  else Load fails
    Engine->>Engine: Exit
  end
Loading

Reviews (2): Last reviewed commit: "feat(commandline): Add -loadsave option ..." | Re-trigger Greptile

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add -loadsave command line option

1 participant