From 33888f7ca69661b44b8799f57a435f8a405c9de7 Mon Sep 17 00:00:00 2001 From: "Robert C. Helling" Date: Fri, 5 Dec 2014 15:13:05 +0100 Subject: [PATCH] In diveplan differentiate between last printed depth and last depth In the decision if a dive segment should lead to a line in the diveplan, we need to differentiate between the lastdepth (the depth of the last dp to tell if we are currently stopping) and the last depth that we printed a line for (needed for gaschange lines). Without this patch, no stops without gas changes were listed anymore in the diveplan. Like the last patch for the diveplan: I hope this time I got this logic right. Signed-off-by: Robert C. Helling --- planner.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/planner.c b/planner.c index bad995e..d6f1983 100644 --- a/planner.c +++ b/planner.c @@ -514,7 +514,7 @@ static unsigned int *sort_stops(int *dstops, int dnr, struct gaschanges *gstops, static void add_plan_to_notes(struct diveplan *diveplan, struct dive *dive, bool show_disclaimer, int error) { char buffer[20000], temp[1000]; - int len, lastdepth = 0, lasttime = 0, lastsetpoint = -1, newdepth = 0; + int len, lastdepth = 0, lasttime = 0, lastsetpoint = -1, newdepth = 0, lastprintdepth = 0; struct divedatapoint *dp = diveplan->dp; bool gaschange = !plan_verbatim, postponed = plan_verbatim; struct divedatapoint *nextdp = NULL; @@ -587,7 +587,7 @@ static void add_plan_to_notes(struct diveplan *diveplan, struct dive *dive, bool if (nextdp && (gasmix_distance(&gasmix, &newgasmix) || dp->setpoint != nextdp->setpoint)) gaschange = true; if (plan_verbatim) { - if (dp->depth != lastdepth) { + if (dp->depth != lastprintdepth) { if (plan_display_transitions || dp->entered || !dp->next || (gaschange && dp->next && dp->depth != nextdp->depth)) { if (dp->setpoint) snprintf(temp, sizeof(temp), translate("gettextFromC", "Transition to %.*f %s in %d:%02d min - runtime %d:%02u on %s (SP = %.1fbar)"), @@ -684,7 +684,8 @@ static void add_plan_to_notes(struct diveplan *diveplan, struct dive *dive, bool gasmix = newgasmix; } } - lastdepth = newdepth; + lastprintdepth = newdepth; + lastdepth = dp->depth; lastsetpoint = dp->setpoint; } while ((dp = nextdp) != NULL); len += snprintf(buffer + len, sizeof(buffer) - len, ""); -- 1.9.3 (Apple Git-50)