Skip to content

Commit

Permalink
Merge #3854 Handle missing KSP2 exe
Browse files Browse the repository at this point in the history
  • Loading branch information
HebaruSan committed Jul 3, 2023
2 parents 94690ea + f5ca34d commit 1ecec0a
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ All notable changes to this project will be documented in this file.
- [Core] Scan for DLLs with or without primary mod dir (#3837 by: HebaruSan; reviewed: techman83)
- [GUI] Show download errors for upgrades (#3840 by: HebaruSan; reviewed: techman83)
- [Core] Stop trying to check free space on Mono (#3850 by: HebaruSan; reviewed: techman83)
- [Core] Handle missing KSP2 exe (#3854 by: HebaruSan; reviewed: techman83)

### Internal

Expand Down
12 changes: 8 additions & 4 deletions Core/Games/KerbalSpaceProgram2.cs
Original file line number Diff line number Diff line change
Expand Up @@ -180,10 +180,14 @@ public void RefreshVersions()
public List<GameVersion> KnownVersions => versions;

public GameVersion DetectVersion(DirectoryInfo where)
=> GameVersion.Parse(
FileVersionInfo.GetVersionInfo(
Path.Combine(where.FullName, "KSP2_x64.exe")).ProductVersion
?? versions.Last().ToString());
=> VersionFromFile(Path.Combine(where.FullName, "KSP2_x64.exe"));

private GameVersion VersionFromFile(string path)
=> File.Exists(path)
? GameVersion.Parse(
FileVersionInfo.GetVersionInfo(path).ProductVersion
?? versions.Last().ToString())
: null;

public string CompatibleVersionsFile => "compatible_game_versions.json";

Expand Down

0 comments on commit 1ecec0a

Please sign in to comment.