Skip to content

Commit

Permalink
Fix calculation of vessel target transfers
Browse files Browse the repository at this point in the history
  • Loading branch information
HebaruSan committed Feb 8, 2017
1 parent e98b16f commit ba8cbba
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
4 changes: 1 addition & 3 deletions src/KerbalTools.cs
Original file line number Diff line number Diff line change
Expand Up @@ -105,9 +105,7 @@ public static CelestialBody StartBody(CelestialBody b = null, Vessel v = null)
/// <param name="target">Body or vessel to use</param>
public static ITargetable StartBody(ITargetable target = null)
{
return target?.GetVessel()?.mainBody
?? target
?? FlightGlobals.GetHomeBody();
return target ?? FlightGlobals.GetHomeBody();
}

/// <summary>
Expand Down
9 changes: 8 additions & 1 deletion src/TransferModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,13 @@ public TransferModel(CelestialBody org, ITargetable dest, Vessel v, int order)

private BurnModel GenerateEjectionBurn(Orbit currentOrbit)
{
if (currentOrbit == null || destination == null) {
if (currentOrbit == null) {
DbgFmt("Skipping transfer from null starting orbit.");
// Sanity check just in case something unexpected happens.
return null;

} else if (destination == null) {
DbgFmt("Skipping transfer to null destination.");
// Sanity check just in case something unexpected happens.
return null;

Expand Down Expand Up @@ -96,6 +102,7 @@ private BurnModel GenerateEjectionBurn(Orbit currentOrbit)

if (origin == immediateDestination as CelestialBody) {
// Trying to get to the start SOI or one of its sub-SOIs
DbgFmt("Skipping origin destination");
return null;
}

Expand Down

0 comments on commit ba8cbba

Please sign in to comment.