From a3f381befee72aaa0f899d2c2b4f028ac3231f56 Mon Sep 17 00:00:00 2001 From: pleroy Date: Tue, 2 Jul 2024 21:26:06 +0200 Subject: [PATCH 1/2] Detect misplaced DLL. --- ksp_plugin_adapter/loader.cs | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/ksp_plugin_adapter/loader.cs b/ksp_plugin_adapter/loader.cs index eab45201c3..492efb7aec 100644 --- a/ksp_plugin_adapter/loader.cs +++ b/ksp_plugin_adapter/loader.cs @@ -47,11 +47,22 @@ internal static string LoadPrincipiaDllAndInitGoogleLogging() { " is not supported at this time."; } if (!possible_dll_paths.Any(File.Exists)) { + string[] where_did_they_put_the_dll = Directory.GetFiles( + Directory.GetCurrentDirectory(), + "principia.dll", + SearchOption.AllDirectories); + string incorrectly_installed_in = ""; + if (where_did_they_put_the_dll.Any()) { + incorrectly_installed_in = " It was incorrectly installed in " + + string.Join(", ", + where_did_they_put_the_dll); + } return "The principia DLL was not found at '" + string.Join("', '", possible_dll_paths) + "' in directory '" + Directory.GetCurrentDirectory() + - "'."; + "'." + + incorrectly_installed_in; } string non_ascii_path_error = null; foreach (char c in Directory.GetCurrentDirectory()) { From f5ee751e9cbfa2593f591f7a7f9b63a8691c58ee Mon Sep 17 00:00:00 2001 From: pleroy Date: Tue, 2 Jul 2024 21:31:15 +0200 Subject: [PATCH 2/2] Make it work on all OSes. --- ksp_plugin_adapter/loader.cs | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/ksp_plugin_adapter/loader.cs b/ksp_plugin_adapter/loader.cs index 492efb7aec..1b7fb92a4d 100644 --- a/ksp_plugin_adapter/loader.cs +++ b/ksp_plugin_adapter/loader.cs @@ -18,6 +18,7 @@ internal static string LoadPrincipiaDllAndInitGoogleLogging() { "use the 64-bit KSP executable."; } string[] possible_dll_paths; + string dll_filename; bool? is_cxx_installed; string required_cxx_packages; switch (Environment.OSVersion.Platform) { @@ -26,15 +27,18 @@ internal static string LoadPrincipiaDllAndInitGoogleLogging() { required_cxx_packages = "the Microsoft Visual C++ 2015-2022 Redistributable (x64) - " + "14.38.33130"; - possible_dll_paths = new [] {@"GameData\Principia\x64\principia.dll"}; + dll_filename = "principia.dll"; + possible_dll_paths = new [] + { @"GameData\Principia\x64\" + dll_filename }; break; // Both Mac and Linux report |PlatformID.Unix|, so we treat them together // (we probably don't actually encounter |PlatformID.MacOSX|). case PlatformID.Unix: case PlatformID.MacOSX: + dll_filename = "principia.so"; possible_dll_paths = new [] { - @"GameData/Principia/Linux64/principia.so", - @"GameData/Principia/MacOS64/principia.so" + @"GameData/Principia/Linux64/" + dll_filename, + @"GameData/Principia/MacOS64/" + dll_filename, }; is_cxx_installed = null; required_cxx_packages = "libc++abi1-17, libc++1-17, and libunwind-17 " + @@ -49,13 +53,14 @@ internal static string LoadPrincipiaDllAndInitGoogleLogging() { if (!possible_dll_paths.Any(File.Exists)) { string[] where_did_they_put_the_dll = Directory.GetFiles( Directory.GetCurrentDirectory(), - "principia.dll", + dll_filename, SearchOption.AllDirectories); string incorrectly_installed_in = ""; if (where_did_they_put_the_dll.Any()) { incorrectly_installed_in = " It was incorrectly installed in " + string.Join(", ", - where_did_they_put_the_dll); + where_did_they_put_the_dll) + + "."; } return "The principia DLL was not found at '" + string.Join("', '", possible_dll_paths) +