Closed QuintillusCFC closed 2 years ago
Ah, I seem to have misunderstood the default value parameter: https://docs.microsoft.com/en-us/dotnet/api/microsoft.win32.registry.getvalue?view=net-6.0 . The registry is weird sometimes, but I get the problem now. I'll see if I can fix it real quick.
Created branch with fix: https://github.com/C7-Game/Prototype/tree/winregfix
I haven't tested it on Windows yet, but it doesn't crash Mac. Yay.
I just tried it on Windows. It works as expected with the registry right, when the install_path value missing, and with the key missing.
I originally thought there was a problem because the button didn't show up, but the button PR hasn't been merged yet, and that's why it's "missing".
Should I make a PR for winregfix or just merge it into PR #78? They're both dealing with the Civ3 home path.
I'd just as soon merge the existing approved PR, and open up a separate one for this. TBH it wouldn't matter a ton in this case, but "I'll just toss one more thing on this PR" can lead to really large PRs.
Also going to assign it to you since it's now in progress.
Stumbled upon this while reviewing Jim's PR.
Steps to reproduce:
Expected: You are able to select the Civ3 home. Actual: C7 crashes. Output:
The fact that it can't find the main menu music is a red herring, the real problem is that it's even trying to despite the registry not containing the expected key. The relevant code in GetCiv3Path():
It turns out that the method we use in Civ3PathFromRegistry to check the registry returns null if it doesn't find anything, but out code expects it to return the empty string.
Of note is that I've tested this on Windows 8.1 64-bit. I know the Windows registry format has not been entirely the same for the past 30 years, so it's possible that it does return the empty string on another version of Windows. I have separate registry-parsing code for pre-and-post-Vista in my editor, so it's not a wholly theoretical possibility.