diff options
author | Robert C. Helling <helling@atdotde.de> | 2014-12-05 15:13:05 +0100 |
---|---|---|
committer | Dirk Hohndel <dirk@hohndel.org> | 2014-12-07 09:45:25 -0600 |
commit | 8cd5d08ba9380a40e3cdcb295b91526bea6c0bd8 (patch) | |
tree | cbc2f257cc12ac7cb55dfcd57638bc861d247328 /planner.c | |
parent | bac2b928603d579cb7bb71a8984a3fa3cd847613 (diff) | |
download | subsurface-8cd5d08ba9380a40e3cdcb295b91526bea6c0bd8.tar.gz |
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>
Diffstat (limited to 'planner.c')
-rw-r--r-- | planner.c | 7 |
1 files changed, 4 insertions, 3 deletions
@@ -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>"); |