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 <helling@atdotde.de>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
Robert C. Helling 2014-12-05 15:13:05 +01:00 committed by Dirk Hohndel
parent bac2b92860
commit 8cd5d08ba9

View file

@ -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, "</tbody></table></div>");