Skip to content

detect XDG compliant games on Linux, obsolete !111, <3 Ingar

Thomas Debesse requested to merge illwieckz/netradiant:xdgpath into master

This implementation looks to be the cleanest way to do it without breaking .game and game_*.c file compatibility across forks.

Netradiant

NetRadiant makes some divination based on prefix, basically if prefix is .unvanquished (example)

  • on Windows it uses (striping the leading dot): [HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders\Personal]\My Games\unvanquished
  • on Mac OS was expected to use (striping the leading dot): ${HOME}/Library/Application Support/unvanquished
  • on Linux it used in any case: ${HOME}/.unvanquished

Now on Linux

  • if ${XDG_DATA_HOME}/unvanquished exists (striping the leading dot) it uses: ${XDG_DATA_HOME}/unvanquished
  • otherwise it uses: ${HOME}/.unvanquished

Note that because of a bug MacOS behaved like Linux but was never detected because build is broken since before the introduction of that bug, that bug is now fixed by an extra commit but the build is not fixed yet (this is out of topic).

Note that some games like Unvanquished use …\My Games\Unvanquished on Windows and …/Library/Application Support/Unvanquished on Mac and it only works because both Windows and Mac default filesystem is case insensitive, that issue is out of topic in this MR.

q3map2

Something is done the same way on q3map2 side, except q3map2 historically does nothing on Windows and was broken on MacOS. An extra commit fixes MacOS but Windows is left untouched (it's still broken but it's not a regression so it's OK).

Note that q3map2 allows to set an arbitrary home path, so the code checks against the default one to know if the prefix needs a leading dot or not.

$ ./q3map2 -fs_nomagicpath -game unvanquished | grep '^VFS Init'
VFS Init: /home/illwieckz/.local/share/unvanquished/pkg/

$ ./q3map2 -fs_nomagicpath -game unvanquished -fs_home /DATA | grep '^VFS Init'
VFS Init: /DATA/unvanquished/pkg/

$ ./q3map2 -fs_nomagicpath -game xonotic | grep '^VFS Init'
VFS Init: /home/illwieckz/.xonotic/data/

$ ./q3map2 -fs_nomagicpath -game xonotic -fs_home /DATA | grep '^VFS Init'
VFS Init: /DATA/.xonotic/data/

In both NetRadiant and q3map2 the ${XDG_DATA_HOME}/prefix scheme is only triggered when directory exists, hence if the game run already one time before and created it. This mean netradiant would create a wrong directory if run before the game creates the XDG directory. It's sad but at least it's not a regression: the bug was always there. On the q3map2 side, the directory will just be wrong like before if run before the game creates the XDG directory (it's not a regression, it was already broken). I find no easy way to fix this, by the way it's not a regression. NetRadiant and q3map2 do really nasty things!

Edited by Thomas Debesse

Merge request reports