-
Notifications
You must be signed in to change notification settings - Fork 89
feat(system): Add command line option to skip force set of cwd #1445
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
…ry to executable path
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah this is nice. I have not thought of that and always enabled the INSTALL build target to test.
Can you please also look over all the tools and do the same there? At a quick glance, GUIEdit, MapCacheBuilder, WorldBuilder also do this. Also can move the common code to a single place to not repeat the same logic in many places.
I did not build or use any tool until just now :). I can have a look, but I would put this into another pull request. For developer tools the solution might be different, like a select directory dialog when it detects that the current working directory is not ok.
What do you mean exactly? I am not that familiar with the code that much. I see that CommandLine.cpp and .h are the same in Generals and ZeroHour, but would it not make sense to move it to Core in a different PR? |
From what I saw the tools use the exact same logic on their startup function. If we can make them behave the same, then that would be nice.
I mean refactor the code in a way that the code duplication for changing the working directory is eliminated. |
In my opinion, the correct fix here is to make the game entirely location agnostic so we don't care what the working directory is. Have both a read only data location and read/write user data location being customisable via either command line, ini file or both. |
This PR introduces the possiblity to put the game executable outside of the Generals/ZeroHour installation path.
Considerations regarding:
I am not able to find any documentation on that.But debugging it with Process Monitor will show when using a Win32 file access function like LoadImageA or LoadCursorFromFile with a relative path, first the executable path, then current working directory, then all paths in %PATH% are searched. See https://learn.microsoft.com/en-us/windows/win32/api/winbase/nf-winbase-openfile#remarksExample usage with VS:
(Sorry for German version, I added "-cwd" to "Command Arguments" and the install path to "Working Directory")