From 8ae82742d7b4b6954207a7fe4cc8a2ab50b70b6c Mon Sep 17 00:00:00 2001 From: "Robert C. Helling" Date: Sun, 27 Nov 2016 11:31:30 +0100 Subject: [PATCH] Fix effective GFs in notes To: subsurface@subsurface-divelog.org This patch fixes two bugs: 1) It first computes the effective gradient factors and then composes the notes with the diveplan rather than the other way around. 2) It does not try to fit a line through a single point. Signed-off-by: Robert C. Helling --- core/deco.c | 2 +- core/planner.c | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/core/deco.c b/core/deco.c index 57acfe9..a445c25 100644 --- a/core/deco.c +++ b/core/deco.c @@ -657,7 +657,7 @@ double get_gf(double ambpressure_bar, const struct dive *dive) double regressiona() { - if (sum1) { + if (sum1 > 1) { double avxy = sumxy / sum1; double avx = (double)sumx / sum1; double avy = sumy / sum1; diff --git a/core/planner.c b/core/planner.c index 488fcb9..ccb71c3 100644 --- a/core/planner.c +++ b/core/planner.c @@ -1362,15 +1362,15 @@ bool plan(struct diveplan *diveplan, char **cached_datap, bool is_planner, bool } while (!is_final_plan); plan_add_segment(diveplan, clock - previous_point_time, 0, current_cylinder, po2, false); - create_dive_from_plan(diveplan, is_planner); - add_plan_to_notes(diveplan, &displayed_dive, show_disclaimer, error); - fixup_dc_duration(&displayed_dive.dc); - if(prefs.deco_mode == VPMB) { diveplan->eff_gfhigh = rint(100.0 * regressionb()); diveplan->eff_gflow = rint(100*(regressiona() * first_stop_depth + regressionb())); } + create_dive_from_plan(diveplan, is_planner); + add_plan_to_notes(diveplan, &displayed_dive, show_disclaimer, error); + fixup_dc_duration(&displayed_dive.dc); + free(stoplevels); free(gaschanges); free(bottom_cache); -- 2.9.3 (Apple Git-75)