-
Notifications
You must be signed in to change notification settings - Fork 251
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
Enhance multiple base directory usage #628
base: main
Are you sure you want to change the base?
Conversation
Make case-insensitive path work on all path components instead of only filename.
Fix error message when real_name is empty.
First added entries to base directories has higher priority on search path.
ddio_GetPrefPath() implements retrieving writable location path. ddio_GetBasePath() implements retrieving parent path of executable.
After initialization, we get following base directories list (in priority order): * Writable preference path * User defined paths (cmd-line and configuration) * Platform defined paths (such as /usr/share/Descent3 on Linux or Steam installation paths on all platforms (TBD)) * Directory of executable Removing `-setdir` and `-useexedir` as redundant (both can be replaced with `-additionaldir` option).
Convert functions to use std::fs::path, minor cleanups.
…s::path Write custom graphics and sounds to writable base directory.
Now screenshots are saved in "screenshots" directory of writable base path. Fix minor issues.
Really nice, I'm not sure yet how this fixes #373 though |
Changes implements platform specific file locations for read (/usr/share/Descent3), it's critical piece for Linux distribution packagers. |
it is! I hope we can still get the XDG runtime variables in there to make the packagers happier |
At the moment, files in Why did you make that change? |
Writable base directory should have highest priority as user can override in that way underlying files. Additional dirs is just another way to provide additional paths to search locations. |
OK, so it sounds like you’re saying that users would not be able to override the underlying files if you changed the order to this:
Am I understanding you correctly? |
Priority of paths is described as follows:
|
I don’t think that you understood my question. My question was about a hypothetical change to your code. Your answer was about the actual code that you currently have written.
I agree that that is how this pull request is currently implemented. The problem is: I don’t know why you implemented it that way. I don’t know why you changed the order from “ Let’s say that you changed your code so that it searched through directories in this order:
Based on your previous comment, it sounds like the user would not be able to override the underlying files if that change was made. Am I understanding correctly? |
First of all, current logic of additionaldir implements same way of search path, they get added after of writable path. My PR changes Writable path is highest priority, because user controls it and can do anything in that path.
In case where override placed in both places priority goes to writable path, because user controls it. In case if such clash undesirable, user always can remove file from writable path. Opposite case (where additional dir is highest priority) may not allows to user remove file (it's read-only for him), so only solution here is remove additionaldir, which is also undesirable. |
I partially agree with you here, but I also partially disagree. I agree that the current working directory and the executable directory might not by writable by the current user. I also agree that this PR prevents Descent 3 from trying to write to the current working directory, and I agree that that is a good thing. Finally, I agree that the
The code that you linked to clearly shows that the /* The "root" directories of the D3 file tree
*
* Directories that come later in the list override directories that come
* earlier in the list. For example, if Base_directories[0] / "d3.hog" exists
* and Base_directories[1] / "d3.hog" also exists, then the one in
* Base_directories[1] will get used. The one in Base_directories[0] will be
* ignored.
*/
std::vector<std::filesystem::path> Base_directories = {}; When I worked on the If you know of any places in the code where I accidentally iterate forwards instead of iterating backwards, then please let me know because that’s a bug with my code and I would like to take responsibility for it. Also, I wrote this script to test out my theory. When I run that script, it seems to prove that files in
When I run that script, it seems to prove that (in the
I disagree. I don’t think that the writable base directory should have the highest priority. You are correct that the user controls it and can do anything with it. However, the user also controls what command-line arguments are passed to Descent 3. The user can run
I completely agree with what you wrote here. It looks like you correctly understand this part of the code that I wrote.
That last part sounds vague to me. You said “so only solution here is remove additionaldir, which is also undesirable.” Why is that undesirable? Personally, I think that having the files in the writable base directory override files in the ecwolf --data wl6 --file mod.pk3 If both DOOM2.EXE -file MOD.WAD If both Additionally, switching the override order makes the
Let’s say that a user wants to install the PPICS 2005 mod. At the moment, they can keep things organized by doing this: Descent3 -additionaldir <path-to-mods-folder> If this PR was merged, then the user would have to either delete |
Current logic not working as expected. When I launch local build with custom location of d3.hog, I lose default pilot file (which intended to be in writable path, #534):
Here log from this branch:
|
Hmm… we should probably open an issue for that because that’s definitely a bug. I would open the issue right now, but I’m not sure how to reproduce the bug. I tried to reproduce the bug by following these steps, but the game was able to find the pilot profile successfully:
Is there anything that I need to change about those steps to reproduce? |
Created pilot flie should be in pref path, not in current directory. Again, all writable files (savefiles, pilot files, demos, user content, configuration) should be in writable directory, current path may not be writable. |
As far as I know, the version of the game that’s in the The version of the game that’s in the That being said, I still think that my steps to reproduce are correct for the |
I tested again the changes and logic of this branch, and it does look good enough compared to what we had before. @Jayman2000 are you ok with moving forward with this MR? |
Not really. I put a lot of work into getting the If you guys really think that files in the writable base directory should override files in the
I don’t think that reason is robust at the moment (see this previous comment), but I can help you guys make it more robust if you guys really think that files in the writable base directory should override files in the |
By default, Descent 3 will only look for game files in the current working directory. In order to function properly, Descent 3 needs to look for some of its files in the Nix store. This commit creates a wrapper around the main Descent3 executable that automatically looks in the correct path in the Nix store. Hopefully, this wrapper will only exist temporarily. I have an unfinished Descent 3 pull request that adds a DEFAULT_ADDITIONAL_DIRS CMake option [1]. Once I can finish that pull request (DescentDevelopers/Descent3#623 needs to get merged first), we’ll be able to get rid of this wrapper and use DEFAULT_ADDITIONAL_DIRS instead. Additionally, if DescentDevelopers/Descent3#628 gets merged first, then that pull request will also probably make this wrapper unnecessary. [1]: <DescentDevelopers/Descent3#471>
By default, Descent 3 will only look for game files in the current working directory. In order to function properly, Descent 3 needs to look for some of its files in the Nix store. This commit creates a wrapper around the main Descent3 executable that automatically looks in the correct path in the Nix store. Hopefully, this wrapper will only exist temporarily. I have an unfinished Descent 3 pull request that adds a DEFAULT_ADDITIONAL_DIRS CMake option [1]. Once I can finish that pull request (DescentDevelopers/Descent3#623 needs to get merged first), we’ll be able to get rid of this wrapper and use DEFAULT_ADDITIONAL_DIRS instead. Additionally, if DescentDevelopers/Descent3#628 gets merged first, then that pull request will also probably make this wrapper unnecessary. [1]: <DescentDevelopers/Descent3#471>
By default, Descent 3 will only look for game files in the current working directory. In order to function properly, Descent 3 needs to look for some of its files in the Nix store. This commit creates a wrapper around the main Descent3 executable that automatically looks in the correct path in the Nix store. Hopefully, this wrapper will only exist temporarily. I have an unfinished Descent 3 pull request that adds a DEFAULT_ADDITIONAL_DIRS CMake option [1]. Once I can finish that pull request (DescentDevelopers/Descent3#623 needs to get merged first), we’ll be able to get rid of this wrapper and use DEFAULT_ADDITIONAL_DIRS instead. Additionally, if DescentDevelopers/Descent3#628 gets merged first, then that pull request will also probably make this wrapper unnecessary. [1]: <DescentDevelopers/Descent3#471>
@Lgt2x, and others, I checked this on macOS, and it works like a charm! SDL correctly uses You may recall in the current 1.5.0 patch, double clicking on the |
Pull Request Type
Description
This is further enhancement of #471 feature.
Priority of base directory changed to following list (top is higher priority):
/usr/share/Descent3
on Linux or Steam installation paths on all platforms (TBD))User defined path can be set by
-additionaldir
orGAME_base_directory
in config file.Added
ddio_GetPrefPath()
andddio_GetBasePath()
helper functions for building base directory entries.Make
cf_LocatePathCaseInsensitiveHelper()
to iterate over all path items (previously it's only iterated only on filename of relative path).Update functions related to writable base directory functionality: save / load games, demo writing / playback, logo and audiotaunts, screenshots.
Screenshots now are saved into
<writable base path> / screenshots
with timestamp in name.If cmake project configured with
-DFORCE_PORTABLE_INSTALL=OFF
, Descent3 will search data files in platform defined path (${CMAKE_INSTALL_DATADIR}/Descent3
or/usr/share/Descent3
).Related Issues
Fixes #326
Fixes #373
Fixes #534
Screenshots (if applicable)
Checklist
Additional Comments