Skip to content

Search all Steam libraries for the Civ3 install (#444) - #1075

Open
IcanBENCHurCAT wants to merge 4 commits into
C7-Game:Developmentfrom
IcanBENCHurCAT:fix/steam-library-detection
Open

IcanBENCHurCAT wants to merge 4 commits into
C7-Game:Developmentfrom
IcanBENCHurCAT:fix/steam-library-detection

Conversation

@IcanBENCHurCAT

Copy link
Copy Markdown

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 for libraryfolders.vdf (modern and pre-2021 layouts) and the legacy BaseInstallFolder_N entries in config/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 registry InstallPath and both Program Files folders on Windows, ~/Library/Application Support/Steam on 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 a steam executable found on PATH that contain a steamapps folder (WildWeazel's suggestion). Libraries whose libraryfolders.vdf entry lists app 3910 are checked first, but every listed library is scanned for civ3id.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

  • GOG detection is deliberately not in here; it came up on Steam Install Auto-Detect 2.0 #444 as a possible separate follow-up.
  • Verified locally: QueryCiv3 and EngineTests both build with no errors and no new warnings from these files, and the fixture cases in the new test file pass.

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.
@ajhalme

ajhalme commented Nov 13, 2026

Copy link
Copy Markdown
Contributor

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.

IcanBENCHurCAT and others added 2 commits November 16, 2026 19:27
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.
@ajhalme

ajhalme commented Nov 18, 2026

Copy link
Copy Markdown
Contributor

Did some refactoring and established a pattern in GetCiv3Path() that should hopefully be more natural to extend with a GOG install finder, etc.

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.

@IcanBENCHurCAT

Copy link
Copy Markdown
Author

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):

  • civ3 only in the second steam library: found
  • both libraries have it, only the second lists app 3910: returned the 3910 one
  • CIV3_HOME set to a third folder: env var wins
  • no civ3id.mb anywhere: /civ3/path/not/found, no exception
  • libraryfolders.vdf corrupted on purpose: same, degrades fine
  • legacy config.vdf with BaseInstallFolder_1: found

refactor looks good to me, the finder pattern reads clean.

@WildWeazel

Copy link
Copy Markdown
Member

I'll try this on my Linux since I have a non default library path

@WildWeazel

WildWeazel commented Nov 19, 2026 •

Copy link
Copy Markdown
Member

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:
[INF] 23:23:06 MainMenu: Data dir: /home/travis/Downloads/OpenCiv3automated_build-Linux-x86_64/OpenCiv3automated_build/; settings: /home/travis/Downloads/OpenCiv3automated_build-Linux-x86_64/OpenCiv3automated_build/C7.ini; civ3 install: /home/travis/workspace/Godot/C7/Civ3; standalone media: false, classic media available: false

without:
[INF] 23:25:45 MainMenu: Data dir: /home/travis/Downloads/OpenCiv3automated_build-Linux-x86_64/OpenCiv3automated_build/; settings: /home/travis/Downloads/OpenCiv3automated_build-Linux-x86_64/OpenCiv3automated_build/C7.ini; civ3 install: /mnt/data/SteamLibrary/steamapps/common/Sid Meier's Civilization III Complete; standalone media: false, classic media available: true

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.
@IcanBENCHurCAT

Copy link
Copy Markdown
Author

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Steam Install Auto-Detect 2.0

3 participants