diff --git a/NewHorizons/Builder/ShipLog/MapModeBuilder.cs b/NewHorizons/Builder/ShipLog/MapModeBuilder.cs index c51ece61..6f0e9636 100644 --- a/NewHorizons/Builder/ShipLog/MapModeBuilder.cs +++ b/NewHorizons/Builder/ShipLog/MapModeBuilder.cs @@ -440,6 +440,11 @@ namespace NewHorizons.Builder.ShipLog private static MapModeObject ConstructPrimaryNode(List bodies) { + float DistanceFromPrimary(NewHorizonsBody body) + { + return Mathf.Max(body.Config.Orbit.semiMajorAxis, body.Config.Orbit.staticPosition?.Length() ?? 0f); + } + foreach (NewHorizonsBody body in bodies.Where(b => b.Config.Base.centerOfSolarSystem)) { bodies.Sort((b, o) => b.Config.Orbit.semiMajorAxis.CompareTo(o.Config.Orbit.semiMajorAxis)); diff --git a/NewHorizons/External/Configs/PlanetConfig.cs b/NewHorizons/External/Configs/PlanetConfig.cs index 6119e1a6..1989ffdc 100644 --- a/NewHorizons/External/Configs/PlanetConfig.cs +++ b/NewHorizons/External/Configs/PlanetConfig.cs @@ -287,6 +287,14 @@ namespace NewHorizons.External.Configs // Disable map marker for dream dimensions if (Dream != null && Dream.inDreamWorld) MapMarker.enabled = false; + + // User error #983 + // This will not catch if they wrote the two names slightly differently but oh well don't be stupid + // Ideally we should just check for loops in PlanetGraph + if (Orbit.primaryBody == name) + { + throw new Exception($"You set {name} to orbit itself, that is invalid. The planet will not load."); + } } public void Migrate() diff --git a/NewHorizons/External/SerializableData/MVector3.cs b/NewHorizons/External/SerializableData/MVector3.cs index 33100bc1..f61cb87b 100644 --- a/NewHorizons/External/SerializableData/MVector3.cs +++ b/NewHorizons/External/SerializableData/MVector3.cs @@ -27,6 +27,8 @@ namespace NewHorizons.External.SerializableData return new Vector3(vec.x, vec.y, vec.z); } + public float Length() => Mathf.Sqrt(x * x + y * y + z * z); + public override string ToString() => $"{x}, {y}, {z}"; } }