Skip to content

Commit

Permalink
* **FIX**: Fixed internal burn time handling on TestFlightReliability…
Browse files Browse the repository at this point in the history
…_EngineCycle
  • Loading branch information
jwvanderbeck committed Mar 26, 2016
1 parent 40cbd88 commit 9dd8cbb
Show file tree
Hide file tree
Showing 5 changed files with 5 additions and 2 deletions.
Binary file modified GameData/TestFlight/Plugins/TestFlight.dll
Binary file not shown.
Binary file modified GameData/TestFlight/Plugins/TestFlightAPI.dll
Binary file not shown.
Binary file modified GameData/TestFlight/Plugins/TestFlightContracts.dll
Binary file not shown.
Binary file modified GameData/TestFlight/Plugins/TestFlightCore.dll
Binary file not shown.
7 changes: 5 additions & 2 deletions TestFlightReliability_EngineCycle.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ public class TestFlightReliability_EngineCycle : TestFlightReliabilityBase


[KSPField(isPersistant = true)]
public double engineOperatingTime = 0f;
public double engineOperatingTime = 0d;
[KSPField(isPersistant = true)]
public double previousOperatingTime = 0d;

Expand All @@ -47,19 +47,22 @@ protected void UpdateCycle()
{
double currentTime = Planetarium.GetUniversalTime();
double deltaTime = (currentTime - previousOperatingTime) / 1d;
Log(String.Format("TestFlightReliability_EngineCycle: previous time: {0:F4}, current time: {1:F4}, delta time: {2:F4}", previousOperatingTime, currentTime, deltaTime));
if (deltaTime >= 1d)
{
previousOperatingTime = currentTime;
// Is our engine running?
if (!core.IsPartOperating())
{
// If not then we optionally cool down the engine, which decresses the burn time used
engineOperatingTime = engineOperatingTime - (idleDecayRate * deltaTime);
engineOperatingTime = Math.Max(engineOperatingTime - (idleDecayRate * deltaTime), 0d);
}
else
{
// If so then we add burn time based on time passed, optionally modified by the thrust
Log(String.Format("TestFlightReliability_EngineCycle: Engine Thrust {0:F4}", engine.finalThrust));
float actualThrustModifier = thrustModifier.Evaluate(engine.finalThrust);
Log(String.Format("TestFlightReliability_EngineCycle: delta time: {0:F4}, operating time :{1:F4}, thrustModifier: {2:F4}", deltaTime, engineOperatingTime, actualThrustModifier));
engineOperatingTime = engineOperatingTime + (deltaTime * actualThrustModifier);

// Check for failure
Expand Down

0 comments on commit 9dd8cbb

Please sign in to comment.