diff --git a/GameData/RealSolarSystem/RealSolarSystem.cfg b/GameData/RealSolarSystem/RealSolarSystem.cfg index 7acd1a3c..cbaf6f3f 100644 --- a/GameData/RealSolarSystem/RealSolarSystem.cfg +++ b/GameData/RealSolarSystem/RealSolarSystem.cfg @@ -17,10 +17,10 @@ REALSOLARSYSTEM cam01FarClip = 1875000 } } -} - -RSSRUNWAYFIX -{ - debug = false - holdThreshold = 2700 + + RSSRUNWAYFIX + { + debug = false + holdThreshold = 2700 + } } diff --git a/Source/CommNetFixer.cs b/Source/CommNetFixer.cs index eb053b9c..8e05164d 100644 --- a/Source/CommNetFixer.cs +++ b/Source/CommNetFixer.cs @@ -1,5 +1,6 @@ using CommNet; using System; +using System.Linq; using UnityEngine; namespace RealSolarSystem @@ -19,23 +20,25 @@ public void Start() Debug.Log("[RealSolarSystem] Checking for custom CommNet settings..."); - foreach (ConfigNode RSSSettings in GameDatabase.Instance.GetConfigNodes("REALSOLARSYSTEM")) - { - RSSSettings.TryGetValue("overrideCommNetParams", ref overrideCommNetParams); - RSSSettings.TryGetValue("enableGroundStations", ref enableExtraGroundStations); - RSSSettings.TryGetValue("occlusionMultiplierAtm", ref occlusionMultiplierInAtm); - RSSSettings.TryGetValue("occlusionMultiplierVac", ref occlusionMultiplierInVac); - } + ConfigNode node = GameDatabase.Instance.GetConfigNodes("REALSOLARSYSTEM").FirstOrDefault(); - if (overrideCommNetParams) + if (node != null) { - // Set the default CommNet parameters for RealSolarSystem. + node.TryGetValue("overrideCommNetParams", ref overrideCommNetParams); + node.TryGetValue("enableGroundStations", ref enableExtraGroundStations); + node.TryGetValue("occlusionMultiplierAtm", ref occlusionMultiplierInAtm); + node.TryGetValue("occlusionMultiplierVac", ref occlusionMultiplierInVac); + + if (overrideCommNetParams) + { + // Set the default CommNet parameters for RealSolarSystem. - Debug.Log("[RealSolarSystem] Updating the CommNet settings..."); + Debug.Log("[RealSolarSystem] Updating the CommNet settings..."); - HighLogic.CurrentGame.Parameters.CustomParams().enableGroundStations = enableExtraGroundStations; - HighLogic.CurrentGame.Parameters.CustomParams().occlusionMultiplierAtm = occlusionMultiplierInAtm; - HighLogic.CurrentGame.Parameters.CustomParams().occlusionMultiplierVac = occlusionMultiplierInVac; + HighLogic.CurrentGame.Parameters.CustomParams().enableGroundStations = enableExtraGroundStations; + HighLogic.CurrentGame.Parameters.CustomParams().occlusionMultiplierAtm = occlusionMultiplierInAtm; + HighLogic.CurrentGame.Parameters.CustomParams().occlusionMultiplierVac = occlusionMultiplierInVac; + } } } catch (Exception exceptionStack) diff --git a/Source/RSSRunwayFix.cs b/Source/RSSRunwayFix.cs index 60562d37..d041282d 100644 --- a/Source/RSSRunwayFix.cs +++ b/Source/RSSRunwayFix.cs @@ -1,4 +1,5 @@ using System.Collections; +using System.Linq; using UnityEngine; using static RunwayCollisionHandler; @@ -43,14 +44,16 @@ public void Awake() public void Start() { - foreach (ConfigNode n in GameDatabase.Instance.GetConfigNodes("RSSRUNWAYFIX")) + ConfigNode node = GameDatabase.Instance.GetConfigNodes("REALSOLARSYSTEM").FirstOrDefault(n => n.HasNode("RSSRUNWAYFIX"))?.GetNode("RSSRUNWAYFIX"); + + if (node != null) { - if (bool.TryParse(n.GetValue("debug"), out bool bTemp)) + if (bool.TryParse(node.GetValue("debug"), out bool bTemp)) { debug = bTemp; } - if (float.TryParse(n.GetValue("holdThreshold"), out float fTemp)) + if (float.TryParse(node.GetValue("holdThreshold"), out float fTemp)) { holdThreshold = fTemp; } diff --git a/Source/TimeWarpFixer.cs b/Source/TimeWarpFixer.cs index f2e1326d..856c3253 100644 --- a/Source/TimeWarpFixer.cs +++ b/Source/TimeWarpFixer.cs @@ -25,7 +25,7 @@ public void Update() { fixedTimeWarp = true; - ConfigNode twNode = GameDatabase.Instance.GetConfigNodes("REALSOLARSYSTEM").FirstOrDefault(n => n.HasNode("timeWarpRates")); + ConfigNode twNode = GameDatabase.Instance.GetConfigNodes("REALSOLARSYSTEM").FirstOrDefault(n => n.HasNode("timeWarpRates"))?.GetNode("timeWarpRates"); if (twNode != null) { diff --git a/Source/Watchdogs.cs b/Source/Watchdogs.cs index 99ae6319..d748b399 100644 --- a/Source/Watchdogs.cs +++ b/Source/Watchdogs.cs @@ -1,5 +1,6 @@ using UnityEngine; using UnityEngine.Rendering; +using System.Linq; namespace RealSolarSystem { @@ -19,8 +20,7 @@ public class RSSWatchDog : MonoBehaviour public void Start() { - foreach (ConfigNode node in GameDatabase.Instance.GetConfigNodes("REALSOLARSYSTEM")) - rssSettings = node; + rssSettings = GameDatabase.Instance.GetConfigNodes("REALSOLARSYSTEM").FirstOrDefault(n => n.HasNode("ClipPlanes")); GameEvents.onVesselSOIChanged.Add(OnVesselSOIChanged); GameEvents.onVesselSituationChange.Add(OnVesselSituationChanged); @@ -47,7 +47,9 @@ public void Update() Camera[] cameras = Camera.allCameras; string bodyName = FlightGlobals.getMainBody().name; - ConfigNode clipPlaneSettings; + if (rssSettings == null) return; + + ConfigNode clipPlaneSettings = null; if (SystemInfo.graphicsDeviceType == GraphicsDeviceType.Direct3D11 || SystemInfo.graphicsDeviceType == GraphicsDeviceType.Direct3D12) {