Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Steam Install Auto-Detect 2.0 #444

Open
QuintillusCFC opened this issue Apr 22, 2024 · 2 comments
Open

Steam Install Auto-Detect 2.0 #444

QuintillusCFC opened this issue Apr 22, 2024 · 2 comments
Labels
data layer data files, formats, and IO windows Specific to running on Windows

Comments

@QuintillusCFC
Copy link
Member

Spinning off of #442 ... (tagging @pcen , thanks for confirming how it works on Win11)

Based on our limited sample size, it appears that on Windows 11, the Civ III install path is not set in the registry upon installing the game via Steam. The PR listed above added a check for Civ III in the default Steam folder.

However, not everyone installs Steam to the default folder, and even for those who do, they may install games on a secondary drive. This issue is to handle those cases.

For the first part, it looks like the install path is stored in the registry at Computer\HKEY_LOCAL_MACHINE\SOFTWARE\WOW6432Node\Valve\Steam, with the InstallPath key; in my case it is C:\Games\Steam. This will let you know where Steam is installed, and Civ III can be checked for in that location.

If it isn't found there, the file /config/config.vdf lists the install folders. It's JSON-y but I haven't verified if it's really JSON, and we only need 1% of it, which conveniently is near the beginning:

"InstallConfigStore"
{
	"Software"
	{
		"valve"
		{
			"Steam"
			{
				"BaseInstallFolder_1"		"D:\\Games\\Steam Library"
				"BaseInstallFolder_2"		"G:\\Games\\Steam"

These BaseInstallFolder entries list other Steam directories. Game folders are within the steamapps/common sub-directories of those, just like within the main Steam folder.

The combination of these two steps should theoretically find Civ III reliably whenever it is installed by Steam. We already theoretically have the CD case covered (as in theory it should always set the registry, particularly as the CD implies Windows 8.1 or earlier due to SecuROM being removed in Win10), which leaves GOG detection (when it doesn't set the registry) as the remaining follow up once this one is done.

(@WildWeazel Any pointers on how to detect the Steam install location on Linux? I don't suppose Proton emulates the Windows registry for us? Depending on the complexity it may or may not warrant a spin-off ticket)

@QuintillusCFC QuintillusCFC added windows Specific to running on Windows data layer data files, formats, and IO labels Apr 22, 2024
@WildWeazel
Copy link
Member

WildWeazel commented May 20, 2024

I have no idea, but I have Steam installed as a flatpak in my home partition and Civ3 in a secondary library on another device, so it'll be a fun use case!

Edit: turns out it's easy. https://unix.stackexchange.com/questions/735211/how-to-get-steam-game-install-save-file-path-programmatically

@WildWeazel
Copy link
Member

Elaboration since I just reviewed Civ3Location.cs:

Check if ~/.steam/root/steamapps/libraryfolders.vdf exists, as this will be the user's Steam library configuration. We need to parse this file to look for a library that contains the the app ID "3910". Once found, take this item's path and append "Sid Meier's Civilization III Complete". Unfortunately VDF is Valve's own not-quite-JSON format, but there is a .NET parser available in nuget: https://github.com/shravan2x/Gameloop.Vdf

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
data layer data files, formats, and IO windows Specific to running on Windows
Projects
None yet
Development

No branches or pull requests

2 participants