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

Get KSP2 version from game assembly #4034

Merged

Conversation

HebaruSan
Copy link
Member

@HebaruSan HebaruSan commented Feb 16, 2024

Motivation

Based on how KSP1 works, if/when KSP2 is released for Linux someday, it will have a Linux executable called KSP2.x86_64 instead of a Windows executable called KSP2_x64.exe.

Since KSP2 has no equivalent of KSP1's buildID.txt or readme.txt files, we currently get the game version from the Windows executable's assembly properties. This will no longer be viable once there is a Linux release, and so far there is no sign that the KSP2 devs have heard our pleas to create a buildID.txt equivalent.

Changes

Now we get the KSP2 game version by using Mono.Cecil to retrieve the VersionID.VERSION_TEXT string constant from <GameRoot>/KSP2_x64_Data/Managed/Assembly-CSharp.dll (the main assembly for the game). If this doesn't work, we fall back to the previous method of looking for the EXE's properties.

Thanks to @cheese3660 for showing us where to find this value. 👍

Caveats:

  • This string has five dot-delimited numeric pieces, but our GameVersion type only allows 4, so we have to use .Take(4) to drop the last piece (which is a build ID)
  • Again going by the KSP1 example, the KSP2_x64_Data folder path will probably become KSP2_Data on Linux. At this point I have opted not to overly future-proof this due to the uncertainty of whether that will actually be the case and the complexity of handling multiple folder paths here. If it turns out that we do need this when a Linux port happens, we can tackle it at that point.

Fixes #3990.

@HebaruSan HebaruSan added Enhancement New features or functionality Easy This is easy to fix Core (ckan.dll) Issues affecting the core part of CKAN labels Feb 16, 2024
@HebaruSan HebaruSan merged commit dc4f9df into KSP-CKAN:master Feb 16, 2024
8 checks passed
@HebaruSan HebaruSan deleted the feature/mono-cecil-game-version branch February 16, 2024 18:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Core (ckan.dll) Issues affecting the core part of CKAN Easy This is easy to fix Enhancement New features or functionality
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Feature] Get game version from DLLs with Mono.Cecil
1 participant