tweak(gamestate): Support loading save files from absolute paths - #3226
Conversation
PR Summary by QodoLoad CLI save games from absolute paths
AI Description
Diagram
High-Level Assessment
Files changed (7)
|
Code Review by Qodo🐞 Bugs (0) 📘 Rule violations (0) 📎 Requirement gaps (0)
Great, no issues found!Qodo reviewed your code and found no material issues that require reviewTip of the day💡 Did you know, you can ask Qodo to dismiss a finding you disagree with, with your reason on record |
|
| Filename | Overview |
|---|---|
| Core/GameEngine/Source/Common/CommandLine.cpp | Adjusts parseLoadSave to report the number of command-line tokens actually consumed. |
| Core/Libraries/Include/Lib/PathUtil.h | Adds platform-aware path-separator and absolute-path classification helpers. |
| Generals/Code/GameEngine/Source/Common/System/SaveGame/GameState.cpp | Supports absolute save paths and visible queued-load failures in Generals. |
| GeneralsMD/Code/GameEngine/Source/Common/System/SaveGame/GameState.cpp | Mirrors absolute save-path and queued-load error handling for Zero Hour. |
Flowchart
%%{init: {'theme': 'neutral'}}%%
flowchart TD
CLI["-loadsave argument"] --> Queue["Queued save filename"]
Queue --> Validate{"Valid .sav and readable?"}
Validate -- No --> Dialog["Show load-error dialog"]
Dialog --> Menu["Remain on main menu"]
Validate -- Yes --> Path{"Absolute path?"}
Path -- Yes --> Direct["Open path in place"]
Path -- No --> Managed["Resolve under managed Save directory"]
Direct --> Load["Read metadata and load game"]
Managed --> Load
Reviews (7): Last reviewed commit: "feat(cli): Load save files from absolute..." | Re-trigger Greptile
f98d734 to
dec8476
Compare
xezon
left a comment
There was a problem hiding this comment.
The code comments need polishing and a reduction in verbosity.
dec8476 to
e7b47bb
Compare
e7b47bb to
7271f8e
Compare
7271f8e to
80470fe
Compare
80470fe to
c24acb2
Compare
c24acb2 to
56cee98
Compare
-loadsavenormally resolves its argument inside the managed user Save directory, so a file anywhere else has to be copied there before it can be opened. That prevents an operating-system file handler from launching the game directly for a selected.sav.Now absolute paths are opened in place while relative names continue to resolve from the Save directory.
isAbsolutePath(const char*)inPathUtil.hrecognizes a drive root (C:\orC:/), a current-drive or UNC root (a leading separator), or a POSIX root.GameState::getSaveGamePathForReadpreserves absolute paths and resolves relative names through the managed directory. Save writes and the save menu are unchanged.parseLoadSavenow returns 2 only when it consumes an argument and 1 otherwise. Previously it returned 2 unconditionally, so-loadsavewithout an argument could consume the following token.Queued save validation runs after the shell is initialized. A wrong extension, missing file, or unreadable file now shows a visible error dialog, and dismissing it leaves the user on the main menu.
Paths containing spaces work when quoted, which is the form an operating-system file handler supplies.
nextParamis quote-aware, so a token beginning with"ends at the matching quote rather than at whitespace.Verified with a bogus path as a control so a successful launch is distinguishable from a successful load:
\\localhost\C$\...)Todo:
z_generalsandg_generals)