From 20a9db779d3a7ba1591e8d336c6b99b80aef71de Mon Sep 17 00:00:00 2001 From: "Robert C. Helling" Date: Tue, 4 Nov 2014 12:15:27 +0100 Subject: Offer to save to a copy in replan mode When replannig a dive, offer another button that creates a new dive rather than overwriting the old. This should help in creating several versions of a planned dive (longer/shorter, deeper/shallower etc). Note that this makes dives that start at the same time not influcence each other's deco. Also, only the first of a row of simultaneous dives contributes to the tissue loadings of later dives. Signed-off-by: Robert C. Helling Signed-off-by: Dirk Hohndel --- divelist.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'divelist.c') diff --git a/divelist.c b/divelist.c index 7efafa88c..9034007b7 100644 --- a/divelist.c +++ b/divelist.c @@ -347,7 +347,7 @@ double init_decompression(struct dive *dive) { int i, divenr = -1; unsigned int surface_time; - timestamp_t when, lasttime = 0; + timestamp_t when, lasttime = 0, laststart = 0; bool deco_init = false; double tissue_tolerance, surface_pressure; @@ -370,8 +370,11 @@ double init_decompression(struct dive *dive) * for how far back we need to go */ if (dive->divetrip && pdive->divetrip != dive->divetrip) continue; - if (!pdive || pdive->when > when || pdive->when + pdive->duration.seconds + 48 * 60 * 60 < when) + if (!pdive || pdive->when >= when || pdive->when + pdive->duration.seconds + 48 * 60 * 60 < when) break; + /* For simultaneous dives, only consider the first */ + if (pdive->when == laststart) + continue; when = pdive->when; lasttime = when + pdive->duration.seconds; } @@ -389,6 +392,7 @@ double init_decompression(struct dive *dive) #endif } add_dive_to_deco(pdive); + laststart = pdive->when; #if DECO_CALC_DEBUG & 2 printf("added dive #%d\n", pdive->number); dump_tissues(); -- cgit v1.2.3-70-g09d2