From 4158a4c7de3701f9e03cd226ab26b6437a47f33e Mon Sep 17 00:00:00 2001 From: Stefan Fuchs Date: Mon, 2 Oct 2017 11:17:10 +0200 Subject: init_deco correctly identify previous dives and report overlapping dives When changing the date/time of a dive in the planner the dive may end up in a totaly new position in respect to date/time of other dives in dive list table. It can be moved to the past or the future before or after other existing dives. It also could overlap with an existing dive. This change enables identification of a new "virtual" dive list position and based on this starts looking for previous dives. Then it (as before the change) does init the deco calculation with any applicable previous dive and surface interval. If some of these applicable dives overlap it returns a neg. surface time which is then used in the planner notes to prohibit display of results. Signed-off-by: Stefan Fuchs --- core/plannernotes.c | 23 ++++++++++++++++------- 1 file changed, 16 insertions(+), 7 deletions(-) (limited to 'core/plannernotes.c') diff --git a/core/plannernotes.c b/core/plannernotes.c index ffbf0b1cb..131820a5b 100644 --- a/core/plannernotes.c +++ b/core/plannernotes.c @@ -85,20 +85,29 @@ void add_plan_to_notes(struct diveplan *diveplan, struct dive *dive, bool show_d len = show_disclaimer ? snprintf(buffer, sz_buffer, "
%s
", disclaimer) : 0; - if (diveplan->surface_interval > 60) { - len += snprintf(buffer + len, sz_buffer - len, "
%s (%s) %s %d:%02d) %s %s
", + if (diveplan->surface_interval < 0) { + len += snprintf(buffer + len, sz_buffer - len, "
%s (%s) %s
", translate("gettextFromC", "Subsurface"), subsurface_canonical_version(), - translate("gettextFromC", "dive plan
(surface interval "), - FRACTION(diveplan->surface_interval / 60, 60), - translate("gettextFromC", "created on"), - get_current_date()); - } else { + translate("gettextFromC", "dive plan
(Overlapping dives detected)")); + dive->notes = strdup(buffer); + free((void *)buffer); + free((void *)temp); + return; + } else if (diveplan->surface_interval >= 48 * 60 *60) { len += snprintf(buffer + len, sz_buffer - len, "
%s (%s) %s %s
", translate("gettextFromC", "Subsurface"), subsurface_canonical_version(), translate("gettextFromC", "dive plan created on"), get_current_date()); + } else { + len += snprintf(buffer + len, sz_buffer - len, "
%s (%s) %s %d:%02d) %s %s
", + translate("gettextFromC", "Subsurface"), + subsurface_canonical_version(), + translate("gettextFromC", "dive plan
(surface interval "), + FRACTION(diveplan->surface_interval / 60, 60), + translate("gettextFromC", "created on"), + get_current_date()); } if (prefs.display_variations) -- cgit v1.2.3-70-g09d2