Repository navigation
Search all Steam libraries for the Civ3 install (#444) - #1075
IcanBENCHurCAT wants to merge 4 commits into
Conversation
GetCiv3Path only checked CIV3_HOME, the Civ3 registry key, and the steamapps/common folder of a default Steam install, so a Steam copy of Civ3 in any other library (or a Steam install outside Program Files) was never found. Add libraryfolders.vdf and legacy config.vdf parsing and scan the listed libraries as a fallback, after the existing checks.
|
Can't really test on my Mac, but seems reasonable, if quite involved. I feel like all the Steam wants to live in a dedicated folder inside QueryCiv3. And I wonder if there's a NuGet library that does most of this discovery. |
SteamLibraries.cs moves under QueryCiv3/Steam (namespace QueryCiv3.Steam) and the Steam root scanning that was added to Civ3Location moves with it as SteamInstallFinder. Civ3Location just calls it after the default steamapps/common check, same order and behaviour as before.
|
Did some refactoring and established a pattern in Also tested on my Linux machine - worked fine. Leaving this open for a bit longer in case somebody wants to test on Windows. But I imagine it's fine. |
|
ran this on windows since you were holding for a windows check. win11, .net 8.0.423, head 00d3406 builds clean and SteamLibrariesTest passes 5/5. no real civ3 install here so i ran GetCiv3Path() against fake installs (folder with a civ3id.mb in it is all the lookup checks for):
refactor looks good to me, the finder pattern reads clean. |
|
I'll try this on my Linux since I have a non default library path |
|
Well I downloaded this build directly and it didn't work, which didn't really surprise me as I have an atypical setup, but then I saw in the log that it did pick up my CIV3_HOME which is a symlink for my local repo. So I unset that and then it did find my obscure steam library (yay) and worked, but that raises the question of why didn't it just go off of CIV3_HOME in the first place? with CIV3_HOME: without: |
EnvVarFinder returned whatever CIV3_HOME pointed at without checking it was a Civ3 install, so a stale or unrelated path (e.g. a dev checkout) short-circuited the registry and Steam searches. Validate with FolderIsCiv3 and fall through when it is not a real install.
|
good catch. it did go off CIV3_HOME, it just never checked the folder actually has civ3 in it, so your symlink to your repo won and then there was no game data there. pushed a fix: the env var finder validates the folder the same way the steam finder does (looks for civ3id.mb) and falls through to the registry/steam search if it is not a real install. with your setup it should now skip the bad CIV3_HOME and find your steam library on its own. added a test covering both cases |
Closes #444
What was changed
QueryCiv3/Civ3Location.cs-GetCiv3Path()now has a fallback that searches the rest of the user's Steam libraries before returning "not found". The existing checks (CIV3_HOME, the Civ3 registry key, the default Steam folder) are untouched and still run first, so installs that are found today resolve exactly the same.QueryCiv3/SteamLibraries.cs(new) - a small parser for Valve's KeyValues/VDF format, plus readers forlibraryfolders.vdf(modern and pre-2021 layouts) and the legacyBaseInstallFolder_Nentries inconfig/config.vdf. Per the discussion on Steam Install Auto-Detect 2.0 #444 this is hand-rolled instead of adding the Gameloop.Vdf package, since these two files are all we need it for.EngineTests/SteamLibrariesTest.cs(new) - tests against fixture VDF files: multi-library setup, legacy config, broken/missing files, and an end-to-end find of a Civ3 folder in a secondary library.Steam roots checked for a
libraryfolders.vdf: the registryInstallPathand both Program Files folders on Windows,~/Library/Application Support/Steamon macOS, and on Linux~/.steam/root,~/.steam/debian-installation,~/.local/share/Steam, the Flatpak root and the Snap root. As a last resort it also tries ancestors of asteamexecutable found on PATH that contain asteamappsfolder (WildWeazel's suggestion). Libraries whoselibraryfolders.vdfentry lists app 3910 are checked first, but every listed library is scanned forciv3id.mb, the same test the default folder gets, because an absent app list doesn't prove Civ3 isn't installed there.Why
Steam installs outside the default folder, and games installed to secondary libraries, were undetectable. On Windows 11 the Civ3 registry key the first check relies on isn't set by a Steam install at all, and on Linux nothing was found unless CIV3_HOME was set.
Notes