summaryrefslogtreecommitdiffstats
path: root/core/planner.c
diff options
context:
space:
mode:
authorGravatar Robert C. Helling <helling@atdotde.de>2017-02-09 18:12:44 +0100
committerGravatar Dirk Hohndel <dirk@hohndel.org>2017-02-11 08:31:42 -0800
commite31714d9b260b37ea2060e051594ad704137d844 (patch)
treefcdd054a99ac485f307804ade01864f9604290b0 /core/planner.c
parent057419fa8528504b5f84dbdb6d7acdb4141d03ee (diff)
downloadsubsurface-e31714d9b260b37ea2060e051594ad704137d844.tar.gz
Set up gaslist only in the beginning of diveplan
In the beginning of the diveplan, divedatapoints of zero duration indicate available gases with the depth giving the suggested switch depth. Zero-duration datapoints in the middle of the dive do not have this meaning and should thus be ignored when composing the gaslist. The tests should have these gas defining segments in the beginning. This fixes a problem when replanning a dive that would change to random gases during deco. Signed-off-by: Robert C. Helling <helling@atdotde.de>
Diffstat (limited to 'core/planner.c')
-rw-r--r--core/planner.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/core/planner.c b/core/planner.c
index a0ab34cf0..8d1cbdc60 100644
--- a/core/planner.c
+++ b/core/planner.c
@@ -426,8 +426,9 @@ static struct gaschanges *analyze_gaslist(struct diveplan *diveplan, int *gascha
struct gaschanges *gaschanges = NULL;
struct divedatapoint *dp = diveplan->dp;
int best_depth = displayed_dive.cylinder[*asc_cylinder].depth.mm;
+ bool total_time_zero = true;
while (dp) {
- if (dp->time == 0) {
+ if (dp->time == 0 && total_time_zero) {
if (dp->depth <= depth) {
int i = 0;
nr++;
@@ -449,6 +450,8 @@ static struct gaschanges *analyze_gaslist(struct diveplan *diveplan, int *gascha
*asc_cylinder = dp->cylinderid;
}
}
+ } else {
+ total_time_zero = false;
}
dp = dp->next;
}