Skip to content

Commit c4837fa

Browse files
committed
Add option to disable awarding du for prelaunch failures
1 parent 9a4c232 commit c4837fa

2 files changed

Lines changed: 10 additions & 3 deletions

File tree

TestFlightAPI/TestFlightAPI/TestFlightFailure.cs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@ public class TestFlightFailureBase : PartModule, ITestFlightFailure
2525
public float duRepair = 0f;
2626
[KSPField]
2727
public bool oneShot = false;
28+
[KSPField]
29+
public bool awardDuInPreLaunch = true;
2830

2931
[KSPField(isPersistant=true)]
3032
public bool failed;
@@ -98,7 +100,7 @@ public virtual void DoFailure()
98100
{
99101
string failMessage;
100102
var failTime = KSPUtil.PrintTimeCompact((int)Math.Floor(this.vessel.missionTime), false);
101-
if (!previouslyFailed)
103+
if (!previouslyFailed && (awardDuInPreLaunch || vessel.situation != Vessel.Situations.PRELAUNCH))
102104
{
103105
core.ModifyFlightData(duFail, true);
104106
failMessage = $"[{failTime}] {core.Title} has failed with {failureTitle}, but this failure has given us valuable data";
@@ -127,7 +129,7 @@ public virtual float DoRepair()
127129
{
128130
Failed = false;
129131
ITestFlightCore core = TestFlightUtil.GetCore(this.part, Configuration);
130-
if (core != null)
132+
if (core != null && (awardDuInPreLaunch || vessel.situation != Vessel.Situations.PRELAUNCH))
131133
core.ModifyFlightData(duRepair, true);
132134
return 0;
133135
}
@@ -160,6 +162,7 @@ public virtual void SetActiveConfig(string alias)
160162
currentConfig.TryGetValue("duFail", ref duFail);
161163
currentConfig.TryGetValue("duRepair", ref duRepair);
162164
currentConfig.TryGetValue("oneShot", ref oneShot);
165+
currentConfig.TryGetValue("awardDuInPreLaunch", ref awardDuInPreLaunch);
163166
}
164167

165168
public virtual List<string> GetTestFlightInfo() => new List<string>();

TestFlightFailure_IgnitionFail.cs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -282,7 +282,11 @@ public override void DoFailure()
282282
ITestFlightCore core = TestFlightUtil.GetCore(this.part, Configuration);
283283
if (core != null)
284284
{
285-
core.ModifyFlightData(duFail, true);
285+
if (awardDuInPreLaunch || vessel.situation != Vessel.Situations.PRELAUNCH)
286+
{
287+
core.ModifyFlightData(duFail, true);
288+
}
289+
286290
string met = KSPUtil.PrintTimeCompact((int)Math.Floor(this.vessel.missionTime), false);
287291
if (dynPressurePenalties)
288292
{

0 commit comments

Comments
 (0)