From 878b5b9bb28ea71b65faf6a6db4eb0af7fc47c4c Mon Sep 17 00:00:00 2001 From: pleroy Date: Thu, 21 Nov 2024 18:28:48 +0100 Subject: [PATCH] More detection of broken mods. --- ksp_plugin_adapter/ksp_plugin_adapter.cs | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/ksp_plugin_adapter/ksp_plugin_adapter.cs b/ksp_plugin_adapter/ksp_plugin_adapter.cs index 1605b0958b..aa2cea31bc 100644 --- a/ksp_plugin_adapter/ksp_plugin_adapter.cs +++ b/ksp_plugin_adapter/ksp_plugin_adapter.cs @@ -733,17 +733,29 @@ public static void LoadTextureOrDie(out UnityEngine.Texture texture, public static double RadiusAt(CelestialBody centre, double latitude, double longitude) { - double altitude = centre.TerrainAltitude( - latitude, - longitude, - allowNegative: !centre.ocean); + double altitude = 0; + try { + altitude = centre.TerrainAltitude(latitude, + longitude, + allowNegative: !centre.ocean); + } catch (Exception e) { + Log.Fatal("Terrain system raised exception " + e.ToString() + + " when computing altitude at latitude " + + latitude + + ", longitude " + + longitude + + " for celestial " + + centre.name + + "; you are probably using a mod incompatible with Principia"); + } if (double.IsNaN(altitude)) { Log.Fatal("Terrain system returned NaN for altitude at latitude " + latitude + ", longitude " + longitude + " for celestial " + - centre.name); + centre.name + + "; you are probably using a mod incompatible with Principia"); } if (double.IsNaN(centre.Radius)) { Log.Fatal("Radius is NaN for celestial " + centre.name);