skullernet / q2pro

Enhanced Quake 2 client and server
GNU General Public License v2.0
248 stars 86 forks source link

motd.txt and maps.lst not loaded in lithium mod because it searches in the wrong path #354

Closed TheShihan closed 1 month ago

TheShihan commented 2 months ago

I try to setup a lithium II server (v. 1.31) using q2pro as a server. I noticed that the configured MOTD and also the maps (maps.lst file) is not being loaded.

After adding some logging to the mod, I saw that the mod tries to load the files from the /usr/share/q2pro directory (installation directory): Attempting to load MOTD file from absolute path: /usr/share/q2pro/lithium/motd.txt

But I have uploaded the lithium mod (gamex86_x64.so) to /home/quake2-server/.q2pro/lithium because this is where q2pro is searching for the file, it doesn't look for the file inside the installation directory:

2024/09/03 21:40:04 | stdout | ]  Loaded game library from /usr/lib/x86_64-linux-gnu/q2pro/baseq2/gamex86_64.so
2024/09/03 21:40:04 | stdout | ]  Can't access /home/quake2-server/.q2pro/baseq2/gamex86_64.so: No such file or directory
2024/09/03 21:40:04 | stdout | ]  Can't access /usr/lib/x86_64-linux-gnu/q2pro/lithium/gamex86_64.so: No such file or directory
2024/09/03 21:40:04 | stdout | ]  Can't access /home/quake2-server/.q2pro/lithium/gamex86_64.so: No such file or directory

So I added the dir /home/quake2-server/.q2pro/lithium as a docker volume and placed the mod files there, but as said the lithium mod does not use this directory to find the files. I believe this is because the working directory is set to /usr/share/q2pro.

I am not sure why this issue occurs. In other mods like OpenTDM or openffa it just works, so I guess it is not necessarily my setup which is at fault? I could of course also additionally add /usr/share/q2pro/lithium as another docker volume and place motd.txt and maps.lst there (I tested it and it worked), but maybe someone can give me an advice why this happens?

skullernet commented 2 months ago

Filesystem access has always been awkward in Q2 mods because there was no game API for it. Each mod has to figure out where to look for files on its own. Most mods simply look for files in ./<gamedir>.

On Linux and similar systems Q2PRO server never changes working directory. Thus for Lithium mod to find its files you need to change working directory to ~/.q2pro before starting q2proded.

It works transparently in OpenFFA because OpenFFA looks for Q2PRO-specific fs_gamedir variable, which is automatically set to full path to current game directory.

TheShihan commented 1 month ago

OK, but why is q2pro only looking for the gamex86_64.so inside the .q2pro subfolders and not inside /usr/share/q2pro where there is also a baseq2?

But yes, I believe I could change the working directory to /home/quake2-server/.q2pro so it would look probalby for the game library and the modt.txt etc. in the right place and I would also have to only map a volume to this folder.

I will check it out..

skullernet commented 1 month ago

OK, but why is q2pro only looking for the gamex86_64.so inside the .q2pro subfolders and not inside /usr/share/q2pro where there is also a baseq2?

Per FHS, shared libraries are installed in/usr/lib. /usr/share is for CPU architecture independent data. For convenience, Q2PRO also looks for shared libraries in home dir.

In your use case it might be easier to build Q2PRO with -Dsystem-wide=false and keep everything in single dir, into which you'll cd.

TheShihan commented 1 month ago

Good to know, maybe I change this the next time. But for the moment I changed the working directory to /home/quake2-server/.q2pro and use two volumes:

This because I have multiple servers and this way they can share the same baseq2 data on the host. Now everything seems to work.