tweak(gamestate): Support load save files from absolute paths - #3226
tweak(gamestate): Support load save files from absolute paths#3226bobtista wants to merge 1 commit into
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 | Makes parseLoadSave consume a second token only when an argument is present. |
| Core/Libraries/Include/Lib/PathUtil.h | Adds platform-aware classification for rooted Windows and POSIX paths. |
| Generals/Code/GameEngine/Source/Common/System/SaveGame/GameState.cpp | Adds absolute-path-aware save reads and visible queued-load validation errors for Generals. |
| GeneralsMD/Code/GameEngine/Source/Common/System/SaveGame/GameState.cpp | Mirrors the save-path and queued-load behavior for Zero Hour. |
| Generals/Code/GameEngine/Include/Common/GameState.h | Declares the new read-path resolver for Generals. |
| GeneralsMD/Code/GameEngine/Include/Common/GameState.h | Declares the corresponding read-path resolver for Zero Hour. |
Flowchart
%%{init: {'theme': 'neutral'}}%%
flowchart TD
A["-loadsave argument"] --> B{"Absolute path?"}
B -- Yes --> C["Use supplied path"]
B -- No --> D["Resolve under user Save directory"]
C --> E["Validate extension and readability"]
D --> E
E -- Valid --> F["Load queued save"]
E -- Invalid --> G["Show error and remain at main menu"]
Reviews (6): 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
| #ifdef _WIN32 | ||
| const Bool hasDriveLetter = (path[0] >= 'A' && path[0] <= 'Z') || (path[0] >= 'a' && path[0] <= 'z'); | ||
| const Bool hasDriveRoot = hasDriveLetter && path[1] == ':' && | ||
| (path[2] == '\\' || path[2] == '/'); |
There was a problem hiding this comment.
And I checked for more, it was just these two that I can see
80470fe to
c24acb2
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)