diff options
Diffstat (limited to 'core')
-rw-r--r-- | core/planner.c | 8 | ||||
-rw-r--r-- | core/plannernotes.c | 8 | ||||
-rw-r--r-- | core/profile.c | 2 |
3 files changed, 16 insertions, 2 deletions
diff --git a/core/planner.c b/core/planner.c index 5bcbdab7e..0177b9691 100644 --- a/core/planner.c +++ b/core/planner.c @@ -1080,6 +1080,14 @@ bool plan(struct deco_state *ds, struct diveplan *diveplan, struct dive *dive, i diveplan->eff_gflow = lrint(100.0 * (regressiona() * first_stop_depth + regressionb())); } + for (int i = 0; i < MAX_CYLINDERS; i++) + if (cylinder_nodata(&dive->cylinder[i])) { + // Switch to an empty air cylinder for breathing air at the surface + // If no empty cylinder is found, keep using last deco gas + current_cylinder = i; + break; + } + plan_add_segment(diveplan, 600, 0, current_cylinder, 0, false, OC); create_dive_from_plan(diveplan, dive, is_planner); add_plan_to_notes(diveplan, dive, show_disclaimer, error); fixup_dc_duration(&dive->dc); diff --git a/core/plannernotes.c b/core/plannernotes.c index 90f37add7..99f456393 100644 --- a/core/plannernotes.c +++ b/core/plannernotes.c @@ -24,9 +24,12 @@ static int diveplan_duration(struct diveplan *diveplan) { struct divedatapoint *dp = diveplan->dp; int duration = 0; + int lastdepth = 0; while(dp) { - if (dp->time > duration) + if (dp->time > duration && (dp->depth.mm > SURFACE_THRESHOLD || lastdepth > SURFACE_THRESHOLD)) { duration = dp->time; + lastdepth = dp->depth.mm; + } dp = dp->next; } return (duration + 30) / 60; @@ -193,6 +196,9 @@ void add_plan_to_notes(struct diveplan *diveplan, struct dive *dive, bool show_d !rebreatherchange_before && !rebreatherchange_after) continue; + // Ignore final surface segment for notes + if (lastdepth == 0 && dp->depth.mm == 0 && !dp->next) + continue; if ((dp->time - lasttime < 10 && lastdepth == dp->depth.mm) && !(gaschange_after && dp->next && dp->depth.mm != dp->next->depth.mm)) continue; diff --git a/core/profile.c b/core/profile.c index 0d568a4fe..9cc072973 100644 --- a/core/profile.c +++ b/core/profile.c @@ -453,7 +453,7 @@ struct plot_info calculate_max_limits_new(struct dive *dive, struct divecomputer if (depth > maxdepth) maxdepth = s->depth.mm; - if ((depth > SURFACE_THRESHOLD || lastdepth > SURFACE_THRESHOLD) && + if ((depth > SURFACE_THRESHOLD || lastdepth > SURFACE_THRESHOLD || in_planner()) && s->time.seconds > maxtime) maxtime = s->time.seconds; lastdepth = depth; |