FWGS / xash3d-fwgs

Xash3D FWGS engine.
1.52k stars 228 forks source link

Unable to Find Game .dlls When Game is Under XASH3D_RODIR Path #1697

Closed mmillar-bolis closed 2 months ago

mmillar-bolis commented 2 months ago

OS: Windows 10 x64 (21H2) CPU: Intel Core i7-8700T @ 2.4GHz GPU: Nvidia GeForce RTX 2060 Xash Build: fe3644a (win32-amd64) Game DLLs: hlsdk-portable/hlfixed (05c6e89)

Issue:

When running the program with the XASH3D_RODIR and XASH3D_BASEDIR environment variables set, the game's server .dll is unable to be found.

Env Var Example:

XASH3D_RODIR=C:\Users\Generic\Program Files\Games\Half-Life\App\Xash3D-Fwgs64
XASH3D_BASEDIR=C:\Users\Generic\Program Files\Games\Half-Life\Data\Profile

Log Example:

[2024:06:23|20:39:01] Error: can't initialize dlls/hl_amd64.dll: The specified module could not be found. 

This issue occurs both if the Game directory is next to xash3d.exe or under a different path. This issue occurs both if the current working directory is the same as the XASH3D_RODIR path, or if it is a different path. Other contents within the Game directory such as .paks and .wads are correctly found.

Log showing issue

Note:

This issue does not seem to affect March builds such as 7584bbe.

a1batross commented 2 months ago

Thanks, I will look into that.

a1batross commented 2 months ago

Fixed https://github.com/FWGS/xash3d-fwgs/commit/5694610478a1df8d0156d17ef8355167ca670ad5

mmillar-bolis commented 2 months ago

Hey, I just wanted to say that this works great and the server/client libraries are now found. Thank you so much!

There is just one thing I am not quite sure about:

As long as the current working directory path is the same as XASH3D_RODIR, the game folder (e.g. valve) is correctly found. If XASH3D_RODIR is different from the current working directory, the game folder will not be found. Is this the intended function?

a1batross commented 2 months ago

What do you mean?.. Can you describe your setup?

XASH3D_RODIR is meant to point at a read-only path, whether it's physically read-only (CD discs, SD cards with write protect pin or OS imposed restrictions) or where you do not intend to write any data (like the Steam library).

XASH3D_BASEDIR is where engine jumps into (it prints in the logfile that current working directory has been changed) and stores all the volatile user data. Anything that can be written gets written there.

Read-only and read-write paths better do not collide. It just makes no sense to set up a read-only path and then just write stuff into it.

a1batross commented 2 months ago

Be aware that not all mods support XASH3D_RODIR. I would even say that no mods actually supports it.

Despite that both GoldSrc and Xash3D FWGS provide access to its virtual filesystem (through filesystem_stdio.dll), not all modders do not know how to use it as it has never been properly documented.

mmillar-bolis commented 2 months ago

Thanks for the response. I see now how I was not very clear, so I will try to clarify:

Before invoking xash3d.exe, I must first pushd into the same directory path as whatever I set XASH3D_RODIR to be.

Example environment:

# Not really an env var of mine, just here to clarify
XASH_BINARY_PATH=C:\Users\Generic\Program Files\Games\Half-Life\App\Xash3D-Fwgs64\xash3d.exe

# Read-only directory of mods
XASH3D_RODIR=C:\Users\Generic\Program Files\Games\Half-Life\App\Mods

# Write-only directory that is used during execution time
XASH3D_BASEDIR=C:\Users\Generic\Program Files\Games\Half-Life\Data\Profile

# The current directory of the shell just before execution time (not matching RODIR)
cd "C:\Users\Generic\Program Files\Games\Half-Life\App\Xash3D-Fwgs64"

.\xash3d.exe

So, in the above example, if I do not pushd away from Xash's directory and into the Mods directory (before I start xash3d.exe), the valve folder will not be found on start-up.

Log showing error condition

If I do pushd into the Mods directory, and then start Xash from a relative path, all is well and I never encounter an error about finding game folders:

# Not really an env var of mine, just here to clarify
XASH_BINARY_PATH=C:\Users\Generic\Program Files\Games\Half-Life\App\Xash3D-Fwgs64\xash3d.exe

# Read-only directory of mods
XASH3D_RODIR=C:\Users\Generic\Program Files\Games\Half-Life\App\Mods

# Write-only directory that is used during execution time
XASH3D_BASEDIR=C:\Users\Generic\Program Files\Games\Half-Life\Data\Profile

# The current directory of the shell just before execution time (matching RODIR)
pushd "C:\Users\Generic\Program Files\Games\Half-Life\App\Mods"

..\Xash3D-Fwgs64\xash3d.exe

popd

I understand that the engine will jump to the write directory during runtime for necessary reasons, but perhaps it may be advisable for me to always set the shell to the Mods directory before executing the path to Xash? I just wanted to check if this step of needing to cd or pushd the shell into the read-only directory just before runtime was intended behavior or not. It was not quite clear to me from the Environment documentation, so I thought I would ask. I don't expect you to change the engine behavior.

Thank you again for all of your great work and support. Xash3d-FWGS just keeps getting better and better!

a1batross commented 2 months ago

This is weird, and I never had issues with it.

What you're encountering is probably a bug, but just today, while I was debugging the engine to resolve this issue, everything worked for me as intended.

mmillar-bolis commented 2 months ago

Okay, not a very big problem. I will investigate further.

My setup involves using the amd64 build of Xash3d-FWGS, and so all 13 or so libraries I am loading are built from hlsdk-portable. So far, these particular libraries are working wonderfully with XASH3D_RODIR and XASH3D_BASEDIR separation, and it is such a relief to be able to keep my mod directories nice and clean. Thank you very much for this feature!

I have encountered one minor, possible bug involving writing gameinfo.txt, so I went ahead and made a separate issue (#1700 ) about it. Thank you again for all your help!