Skip to content

Commit

Permalink
Ensure the craft's orbit is valid at all times
Browse files Browse the repository at this point in the history
The delayed setting of the craft's orbit resulted in the orbit mean
motion being 0 thus producing NaN when queries were made about the orbit
(by kOS, Trajectories, Kerbal Engineer etc). Because kOS and
Trajectories went through OrbitDriver, this would result in the craft
getting deleted, potentially wreaking havoc in the code (especially if
Kerbal Engineer tried to access the orbit as well) and definitely
causing consternation for the player (hey, dude, where's my ship?)

Fixes #163
  • Loading branch information
taniwha committed Sep 5, 2020
1 parent dc76b81 commit aebc56b
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions Source/BuildControl.cs
Original file line number Diff line number Diff line change
Expand Up @@ -651,6 +651,7 @@ internal void BuildAndLaunchCraft ()
craftVessel.launchedFrom = builder.LaunchedFrom;

FlightGlobals.ForceSetActiveVessel (craftVessel);
SetCraftOrbit (craftVessel, OrbitDriver.UpdateMode.IDLE);
builder.PostBuild (craftVessel);
if (builder.capture) {
craftVessel.Splashed = craftVessel.Landed = false;
Expand Down Expand Up @@ -1041,6 +1042,7 @@ public CostReport getBuildCost (ConfigNode craft, string craftText = null)
Vessel craftVessel = ro.AddComponent<Vessel>();
craftVessel.vesselName = "EL craftVessel - " + craft.GetValue ("ship");
craftVessel.Initialize (true);
SetCraftOrbit (craftVessel, OrbitDriver.UpdateMode.IDLE);
foreach (Part part in craftVessel.parts) {
SanitizePart(part);
part.ModulesOnStart();
Expand Down

0 comments on commit aebc56b

Please sign in to comment.