Skip to content

Commit

Permalink
Merge pull request #3407 from eggrobin/keep-fractional-digits
Browse files Browse the repository at this point in the history
Don鈥檛 drop fractional digits when loading a flight plan
  • Loading branch information
pleroy committed Jul 26, 2022
2 parents 0a64241 + b265983 commit 0903764
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions ksp_plugin_adapter/burn_editor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,7 @@ public enum Event {
changed = true;
engine_warning_ = "";
ComputeEngineCharacteristics();
Reformat螖v();
}

// The frame selector is disabled for an anomalous man艙uvre as is has no
Expand All @@ -136,16 +137,19 @@ public enum Event {
L10N.CacheFormat("#Principia_BurnEditor_ActiveEngines"))) {
engine_warning_ = "";
ComputeEngineCharacteristics();
Reformat螖v();
changed = true;
} else if (UnityEngine.GUILayout.Button(
L10N.CacheFormat("#Principia_BurnEditor_ActiveRCS"))) {
engine_warning_ = "";
ComputeRCSCharacteristics();
Reformat螖v();
changed = true;
} else if (UnityEngine.GUILayout.Button(
L10N.CacheFormat("#Principia_BurnEditor_InstantImpulse"))) {
engine_warning_ = "";
UseTheForceLuke();
Reformat螖v();
changed = true;
}
}
Expand Down Expand Up @@ -251,6 +255,16 @@ public enum Event {
}.magnitude;
}

private void Reformat螖v() {
// Ensure that the number of digits used in formatting is consistent with
// the current 螖v values, initial mass, and engine characteristics,
// otherwise the change in the number of significant figures will be
// interpreted as input.
螖v_tangent_.value = 螖v_tangent_.value;
螖v_normal_.value = 螖v_normal_.value;
螖v_binormal_.value = 螖v_binormal_.value;
}

public void Reset(NavigationManoeuvre man艙uvre) {
Burn burn = man艙uvre.burn;
螖v_tangent_.value = burn.delta_v.x;
Expand All @@ -261,6 +275,7 @@ public enum Event {
is_inertially_fixed_ = burn.is_inertially_fixed;
duration_ = man艙uvre.duration;
initial_mass_in_tonnes_ = man艙uvre.initial_mass_in_tonnes;
Reformat螖v();
}

public Burn Burn() {
Expand Down

0 comments on commit 0903764

Please sign in to comment.