Fix to burn times calculated for jet engines (uses ignoreForIsp propellant property)
Fix to burn times calculated for jet engines (uses ignoreForIsp propellant property)

--- a/KerbalEngineer/Flight/Readouts/Rendezvous/RendezvousProcessor.cs
+++ b/KerbalEngineer/Flight/Readouts/Rendezvous/RendezvousProcessor.cs
@@ -1,7 +1,7 @@
 // 
 //     Kerbal Engineer Redux
 // 
-//     Copyright (C) 2014 CYBUTEK
+//     Copyright (C) 2015 CYBUTEK
 // 
 //     This program is free software: you can redistribute it and/or modify
 //     it under the terms of the GNU General Public License as published by
@@ -17,30 +17,19 @@
 //     along with this program.  If not, see <http://www.gnu.org/licenses/>.
 // 
 
-#region Using Directives
-
-using System;
-
-using KerbalEngineer.Extensions;
-using KerbalEngineer.Helpers;
-
-#endregion
-
 namespace KerbalEngineer.Flight.Readouts.Rendezvous
 {
+    using System;
+    using Extensions;
+    using Helpers;
+
     public class RendezvousProcessor : IUpdatable, IUpdateRequest
     {
-        #region Fields
-
         private static readonly RendezvousProcessor instance = new RendezvousProcessor();
 
         private Orbit originOrbit;
         private Orbit targetOrbit;
 
-        #endregion
-
-        #region Properties
-
         /// <summary>
         ///     Gets the target's altitude above its reference body.
         /// </summary>
@@ -71,7 +60,10 @@
         /// </summary>
         public static RendezvousProcessor Instance
         {
-            get { return instance; }
+            get
+            {
+                return instance;
+            }
         }
 
         /// <summary>
@@ -149,10 +141,6 @@
         /// </summary>
         public bool UpdateRequested { get; set; }
 
-        #endregion
-
-        #region Methods: public
-
         /// <summary>
         ///     Request and update to calculate the details.
         /// </summary>
@@ -166,7 +154,13 @@
         /// </summary>
         public void Update()
         {
-            if (FlightGlobals.fetch.VesselTarget == null)
+            if (FlightGlobals.fetch == null ||
+                FlightGlobals.fetch.VesselTarget == null ||
+                FlightGlobals.ActiveVessel == null ||
+                FlightGlobals.ActiveVessel.targetObject == null ||
+                FlightGlobals.ActiveVessel.targetObject.GetOrbit() == null ||
+                FlightGlobals.ship_orbit == null ||
+                FlightGlobals.ship_orbit.referenceBody == null)
             {
                 ShowDetails = false;
                 return;
@@ -174,55 +168,50 @@
 
             ShowDetails = true;
 
-            this.targetOrbit = FlightGlobals.fetch.VesselTarget.GetOrbit();
-            this.originOrbit = (FlightGlobals.ship_orbit.referenceBody == Planetarium.fetch.Sun || FlightGlobals.ship_orbit.referenceBody == FlightGlobals.ActiveVessel.targetObject.GetOrbit().referenceBody)
+            targetOrbit = FlightGlobals.fetch.VesselTarget.GetOrbit();
+            originOrbit = (FlightGlobals.ship_orbit.referenceBody == Planetarium.fetch.Sun ||
+                           FlightGlobals.ship_orbit.referenceBody == FlightGlobals.ActiveVessel.targetObject.GetOrbit().referenceBody)
                 ? FlightGlobals.ship_orbit
                 : FlightGlobals.ship_orbit.referenceBody.orbit;
 
-            RelativeInclination = this.originOrbit.GetRelativeInclination(this.targetOrbit);
+            RelativeInclination = originOrbit.GetRelativeInclination(targetOrbit);
             RelativeVelocity = FlightGlobals.ship_tgtSpeed;
-            RelativeSpeed = FlightGlobals.ship_obtSpeed - this.targetOrbit.orbitalSpeed;
-            PhaseAngle = this.originOrbit.GetPhaseAngle(this.targetOrbit);
-            InterceptAngle = this.CalcInterceptAngle();
-            TimeToAscendingNode = this.originOrbit.GetTimeToVector(this.GetAscendingNode());
-            TimeToDescendingNode = this.originOrbit.GetTimeToVector(this.GetDescendingNode());
-            AngleToAscendingNode = this.originOrbit.GetAngleToVector(this.GetAscendingNode());
-            AngleToDescendingNode = this.originOrbit.GetAngleToVector(this.GetDescendingNode());
-            AltitudeSeaLevel = this.targetOrbit.altitude;
-            ApoapsisHeight = this.targetOrbit.ApA;
-            PeriapsisHeight = this.targetOrbit.PeA;
-            TimeToApoapsis = this.targetOrbit.timeToAp;
-            TimeToPeriapsis = this.targetOrbit.timeToPe;
-            SemiMajorAxis = this.targetOrbit.semiMajorAxis;
-            SemiMinorAxis = this.targetOrbit.semiMinorAxis;
-
-            Distance = Vector3d.Distance(this.targetOrbit.pos, this.originOrbit.pos);
-            OrbitalPeriod = this.targetOrbit.period;
-        }
-
-        #endregion
-
-        #region Methods: private
+            RelativeSpeed = FlightGlobals.ship_obtSpeed - targetOrbit.orbitalSpeed;
+            PhaseAngle = originOrbit.GetPhaseAngle(targetOrbit);
+            InterceptAngle = CalcInterceptAngle();
+            TimeToAscendingNode = originOrbit.GetTimeToVector(GetAscendingNode());
+            TimeToDescendingNode = originOrbit.GetTimeToVector(GetDescendingNode());
+            AngleToAscendingNode = originOrbit.GetAngleToVector(GetAscendingNode());
+            AngleToDescendingNode = originOrbit.GetAngleToVector(GetDescendingNode());
+            AltitudeSeaLevel = targetOrbit.altitude;
+            ApoapsisHeight = targetOrbit.ApA;
+            PeriapsisHeight = targetOrbit.PeA;
+            TimeToApoapsis = targetOrbit.timeToAp;
+            TimeToPeriapsis = targetOrbit.timeToPe;
+            SemiMajorAxis = targetOrbit.semiMajorAxis;
+            SemiMinorAxis = targetOrbit.semiMinorAxis;
+
+            Distance = Vector3d.Distance(targetOrbit.pos, originOrbit.pos);
+            OrbitalPeriod = targetOrbit.period;
+        }
 
         private double CalcInterceptAngle()
         {
-            var originRadius = (this.originOrbit.semiMinorAxis + this.originOrbit.semiMajorAxis) * 0.5;
-            var targetRadius = (this.targetOrbit.semiMinorAxis + this.targetOrbit.semiMajorAxis) * 0.5;
-            var angle = 180.0 * (1.0 - Math.Pow((originRadius + targetRadius) / (2.0 * targetRadius), 1.5));
+            double originRadius = (originOrbit.semiMinorAxis + originOrbit.semiMajorAxis) * 0.5;
+            double targetRadius = (targetOrbit.semiMinorAxis + targetOrbit.semiMajorAxis) * 0.5;
+            double angle = 180.0 * (1.0 - Math.Pow((originRadius + targetRadius) / (2.0 * targetRadius), 1.5));
             angle = PhaseAngle - angle;
             return RelativeInclination < 90.0 ? AngleHelper.Clamp360(angle) : AngleHelper.Clamp360(360.0 - (180.0 - angle));
         }
 
         private Vector3d GetAscendingNode()
         {
-            return Vector3d.Cross(this.targetOrbit.GetOrbitNormal(), this.originOrbit.GetOrbitNormal());
+            return Vector3d.Cross(targetOrbit.GetOrbitNormal(), originOrbit.GetOrbitNormal());
         }
 
         private Vector3d GetDescendingNode()
         {
-            return Vector3d.Cross(this.originOrbit.GetOrbitNormal(), this.targetOrbit.GetOrbitNormal());
-        }
-
-        #endregion
+            return Vector3d.Cross(originOrbit.GetOrbitNormal(), targetOrbit.GetOrbitNormal());
+        }
     }
 }

--- a/KerbalEngineer/Flight/Readouts/Surface/Longitude.cs
+++ b/KerbalEngineer/Flight/Readouts/Surface/Longitude.cs
@@ -17,35 +17,25 @@
 //     along with this program.  If not, see <http://www.gnu.org/licenses/>.
 // 
 
-#region Using Directives
-
-using KerbalEngineer.Flight.Sections;
-
-#endregion
-
 namespace KerbalEngineer.Flight.Readouts.Surface
 {
+    using Helpers;
+    using Sections;
+
     public class Longitude : ReadoutModule
     {
-        #region Constructors
-
         public Longitude()
         {
-            this.Name = "Longitude";
-            this.Category = ReadoutCategory.GetCategory("Surface");
-            this.HelpString = "Shows the vessel's longitude around a celestial body.  Longitude is the angle from the bodies prime meridian.";
-            this.IsDefault = true;
+            Name = "Longitude";
+            Category = ReadoutCategory.GetCategory("Surface");
+            HelpString = "Shows the vessel's longitude around a celestial body.  Longitude is the angle from the bodies prime meridian.";
+            IsDefault = true;
         }
-
-        #endregion
-
-        #region Methods: public
 
         public override void Draw(SectionModule section)
         {
-            this.DrawLine(KSPUtil.PrintLongitude(FlightGlobals.ship_longitude), section.IsHud);
+            double angle = AngleHelper.Clamp180(FlightGlobals.ship_longitude);
+            DrawLine(Units.ToAngleDMS(angle) + (angle < 0.0 ? "W" : " E"), section.IsHud);
         }
-
-        #endregion
     }
 }

--- a/KerbalEngineer/Helpers/AngleHelper.cs
+++ b/KerbalEngineer/Helpers/AngleHelper.cs
@@ -17,21 +17,30 @@
 //     along with this program.  If not, see <http://www.gnu.org/licenses/>.
 // 
 
-#region Using Directives
-
-using UnityEngine;
-
-#endregion
-
 namespace KerbalEngineer.Helpers
 {
+    using UnityEngine;
+
     public static class AngleHelper
     {
-        #region Methods: public
+        public static double Clamp180(double angle)
+        {
+            angle = Clamp360(angle);
+            if (angle > 180.0)
+            {
+                angle = angle - 360.0;
+            }
+            return angle;
+        }
 
-        public static double Clamp360(double value)
+        public static double Clamp360(double angle)
         {
-            return ClampBetween(value, 0.0, 360.0);
+            angle = angle % 360.0;
+            if (angle < 0.0)
+            {
+                angle = angle + 360.0;
+            }
+            return angle;
         }
 
         public static double ClampBetween(double value, double minimum, double maximum)
@@ -51,8 +60,8 @@
 
         public static double GetAngleBetweenVectors(Vector3d left, Vector3d right)
         {
-            var angle = Vector3d.Angle(left, right);
-            var rotated = QuaternionD.AngleAxis(90.0, Vector3d.forward) * right;
+            double angle = Vector3d.Angle(left, right);
+            Vector3d rotated = QuaternionD.AngleAxis(90.0, Vector3d.forward) * right;
 
             if (Vector3d.Angle(rotated, left) > 90.0)
             {
@@ -60,7 +69,5 @@
             }
             return angle;
         }
-
-        #endregion
     }
 }

--- a/KerbalEngineer/KerbalEngineer.csproj
+++ b/KerbalEngineer/KerbalEngineer.csproj
@@ -208,8 +208,7 @@
   </ItemGroup>
   <ItemGroup>
     <Reference Include="Assembly-CSharp">
-      <HintPath>..\..\..\..\..\..\Program Files (x86)\Steam\SteamApps\common\Kerbal Space Program\KSP_Data\Managed\Assembly-CSharp.dll</HintPath>
-      <Private>False</Private>
+      <HintPath>..\Game\KSP_Data\Managed\Assembly-CSharp.dll</HintPath>
     </Reference>
     <Reference Include="System">
       <HintPath>..\Game\KSP_Data\Managed\System.dll</HintPath>
@@ -220,8 +219,7 @@
       <Private>False</Private>
     </Reference>
     <Reference Include="UnityEngine">
-      <HintPath>..\..\..\..\..\..\Program Files (x86)\Steam\SteamApps\common\Kerbal Space Program\KSP_Data\Managed\UnityEngine.dll</HintPath>
-      <Private>False</Private>
+      <HintPath>..\Game\KSP_Data\Managed\UnityEngine.dll</HintPath>
     </Reference>
   </ItemGroup>
   <ItemGroup />

--- a/KerbalEngineer/VesselSimulator/EngineSim.cs
+++ b/KerbalEngineer/VesselSimulator/EngineSim.cs
@@ -31,6 +31,7 @@
         private static readonly Pool<EngineSim> pool = new Pool<EngineSim>(Create, Reset);
 
         private readonly ResourceContainer resourceConsumptions = new ResourceContainer();
+        private readonly ResourceContainer resourceFlowModes = new ResourceContainer();
 
         public double actualThrust = 0;
         public bool isActive = false;
@@ -52,6 +53,7 @@
         private static void Reset(EngineSim engineSim)
         {
             engineSim.resourceConsumptions.Reset();
+            engineSim.resourceFlowModes.Reset();
             engineSim.actualThrust = 0;
             engineSim.isActive = false;
             engineSim.isp = 0;
@@ -98,6 +100,7 @@
             engineSim.isActive = active;
             engineSim.thrustVec = vecThrust;
             engineSim.resourceConsumptions.Reset();
+            engineSim.resourceFlowModes.Reset();
             engineSim.appliedForces.Clear();
 
             double flowRate = 0.0;
@@ -142,7 +145,8 @@
             for (int i = 0; i < propellants.Count; ++i)
             {
                 Propellant propellant = propellants[i];
-                flowMass += propellant.ratio * ResourceContainer.GetResourceDensity(propellant.id);
+                if (!propellant.ignoreForIsp)
+                    flowMass += propellant.ratio * ResourceContainer.GetResourceDensity(propellant.id);
             }
 
             if (log != null) log.buf.AppendFormat("flowMass = {0:g6}\n", flowMass);
@@ -164,6 +168,7 @@
                         theEngine.partId,
                         consumptionRate);
                 engineSim.resourceConsumptions.Add(propellant.id, consumptionRate);
+                engineSim.resourceFlowModes.Add(propellant.id, (double)propellant.GetFlowMode());
             }
 
             double thrustPerThrustTransform = engineSim.thrust / thrustTransforms.Count;
@@ -269,7 +274,7 @@
                     sourcePartSets.Add(type, sourcePartSet);
                 }
 
-                switch (ResourceContainer.GetResourceFlowMode(type))
+                switch ((ResourceFlowMode)this.resourceFlowModes[type])
                 {
                     case ResourceFlowMode.NO_FLOW:
                         if (partSim.resources[type] > SimManager.RESOURCE_MIN && partSim.resourceFlowStates[type] != 0)

--- a/KerbalEngineer/VesselSimulator/Simulation.cs
+++ b/KerbalEngineer/VesselSimulator/Simulation.cs
@@ -139,6 +139,7 @@
                 log.buf.AppendLine("PrepareSimulation started");
                 dumpTree = true;
             }
+            this._timer.Reset();
             this._timer.Start();
 
             // Store the parameters in members for ease of access in other functions
@@ -299,6 +300,7 @@
                 MonoBehaviour.print("RunSimulation started");
             }
 
+            this._timer.Reset();
             this._timer.Start();
 
             LogMsg log = null;

 Binary files a/Output/KerbalEngineer/KerbalEngineer.dll and b/Output/KerbalEngineer/KerbalEngineer.dll differ