Skip to content

Commit

Permalink
Merge branch 'dev'
Browse files Browse the repository at this point in the history
  • Loading branch information
siimav committed Aug 27, 2023
2 parents 41c3d96 + a5cc5ee commit 42dcf3d
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 5 deletions.
5 changes: 4 additions & 1 deletion TestFlightAPI/TestFlightAPI/TestFlightFailure.cs
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,10 @@ public virtual void DoFailure()

}
FlightLogger.eventLog.Add(failMessage);
core.LogCareerFailure(vessel, failureTitle);
if (!previouslyFailed)
{
core.LogCareerFailure(vessel, failureTitle);
}
}
}

Expand Down
20 changes: 17 additions & 3 deletions TestFlightCore/TestFlightCore/TestFlightCore.cs
Original file line number Diff line number Diff line change
Expand Up @@ -561,13 +561,27 @@ public float ModifyFlightData(float modifier, bool additive)
newFlightData = Math.Min(newFlightData, initialFlightData + perFlightMax);
}

// Adjust new flight data if neccesary to stay under the cap
// Adjust new flight data if necessary to stay under the cap
if (dataCap != 1f && newFlightData > (maxData * dataCap))
newFlightData = maxData * dataCap;
if (newFlightData > maxData)
newFlightData = maxData;
// update the scenario store to add (or subtract) the difference between the flight data before calculation and the flight data after (IE the relative change)
TestFlightManagerScenario.Instance.SetFlightDataForPartName(Alias, existingStoredFlightData + (newFlightData - existingData));

float dataToAdd = newFlightData - existingData;
if (perFlightMax > 0f)
{
// Prevent data from multiple engines from overflowing the per-flight cap
float currentFlightCap = initialFlightData + perFlightMax;
float distanceToPerFlightCap = currentFlightCap - existingStoredFlightData;
dataToAdd = Math.Min(distanceToPerFlightCap, dataToAdd);
}

if (!additive || dataToAdd > 0)
{
// update the scenario store to add the difference between the flight data before calculation and the flight data after (IE the relative change)
TestFlightManagerScenario.Instance.SetFlightDataForPartName(Alias, existingStoredFlightData + dataToAdd);
}

// and update our part's saved data on the vessel
currentFlightData = newFlightData;

Expand Down
4 changes: 3 additions & 1 deletion TestFlightFailure_IgnitionFail.cs
Original file line number Diff line number Diff line change
Expand Up @@ -303,6 +303,8 @@ public override void DoFailure()
{
FlightLogger.eventLog.Add($"[{met}] {core.Title} failed: Ignition Failure.");
}

core.LogCareerFailure(vessel, failureTitle);
}
Log($"IgnitionFail: Failing {engines.Count} engine(s)");
for (int i = 0; i < engines.Count; i++)
Expand All @@ -317,7 +319,7 @@ public override void DoFailure()

engine.engine.Shutdown();

if ((restoreIgnitionCharge) || (this.vessel.situation == Vessel.Situations.PRELAUNCH) )
if (restoreIgnitionCharge || this.vessel.situation == Vessel.Situations.PRELAUNCH)
RestoreIgnitor();
engines[i].failEngine = false;
}
Expand Down

0 comments on commit 42dcf3d

Please sign in to comment.