diff --git a/TestFlightAPI/TestFlightAPI/TestFlightFailure.cs b/TestFlightAPI/TestFlightAPI/TestFlightFailure.cs index d157018..a4819ea 100644 --- a/TestFlightAPI/TestFlightAPI/TestFlightFailure.cs +++ b/TestFlightAPI/TestFlightAPI/TestFlightFailure.cs @@ -111,7 +111,10 @@ public virtual void DoFailure() } FlightLogger.eventLog.Add(failMessage); - core.LogCareerFailure(vessel, failureTitle); + if (!previouslyFailed) + { + core.LogCareerFailure(vessel, failureTitle); + } } } diff --git a/TestFlightCore/TestFlightCore/TestFlightCore.cs b/TestFlightCore/TestFlightCore/TestFlightCore.cs index 31a2bd2..8e122d1 100644 --- a/TestFlightCore/TestFlightCore/TestFlightCore.cs +++ b/TestFlightCore/TestFlightCore/TestFlightCore.cs @@ -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; diff --git a/TestFlightFailure_IgnitionFail.cs b/TestFlightFailure_IgnitionFail.cs index db00214..a1f10c4 100644 --- a/TestFlightFailure_IgnitionFail.cs +++ b/TestFlightFailure_IgnitionFail.cs @@ -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++) @@ -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; }