Planner: Avoid bogus segments with 0 time

Don't show a stop if we continue at this depth.

This resolves a problem when there are more than two waypoints during deco
at the same depth. This can happen at 6m when there is a gaschange to O2
and the last stop depth is 6m (which turns the 3m stop into another 6m
stop).

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-06-05 00:15:11 +02:00 committed by Dirk Hohndel
parent 14eb0e23af
commit 9c7284b403

View file

@ -518,6 +518,7 @@ static void add_plan_to_notes(struct diveplan *diveplan, struct dive *dive, bool
struct divedatapoint *dp = diveplan->dp; struct divedatapoint *dp = diveplan->dp;
const char *empty = ""; const char *empty = "";
bool gaschange = !plan_verbatim; bool gaschange = !plan_verbatim;
struct divedatapoint *nextdp;
disclaimer = translate("gettextFromC", "<b>DISCLAIMER / WARNING: THIS IS A NEW IMPLEMENTATION OF THE BUHLMANN " disclaimer = translate("gettextFromC", "<b>DISCLAIMER / WARNING: THIS IS A NEW IMPLEMENTATION OF THE BUHLMANN "
"ALGORITHM AND A DIVE PLANNER IMPLEMENTION BASED ON THAT WHICH HAS " "ALGORITHM AND A DIVE PLANNER IMPLEMENTION BASED ON THAT WHICH HAS "
@ -543,7 +544,6 @@ static void add_plan_to_notes(struct diveplan *diveplan, struct dive *dive, bool
const char *depth_unit; const char *depth_unit;
double depthvalue; double depthvalue;
int decimals; int decimals;
struct divedatapoint *nextdp;
if (dp->time == 0) if (dp->time == 0)
continue; continue;
@ -573,7 +573,7 @@ static void add_plan_to_notes(struct diveplan *diveplan, struct dive *dive, bool
gaschange = true; gaschange = true;
if (plan_verbatim) { if (plan_verbatim) {
if (dp->depth != lastdepth) { if (dp->depth != lastdepth) {
if (plan_display_transitions || dp->entered || !dp->next || (gaschange && dp->next && (dp->depth != dp->next->depth || !dp->next->time))) { if (plan_display_transitions || dp->entered || !dp->next || (gaschange && dp->next && dp->depth != nextdp->depth)) {
len += snprintf(buffer + len, sizeof(buffer) - len, translate("gettextFromC", "Transition to %.*f %s in %d:%02d min - runtime %d:%02u on %s<br>"), len += snprintf(buffer + len, sizeof(buffer) - len, translate("gettextFromC", "Transition to %.*f %s in %d:%02d min - runtime %d:%02u on %s<br>"),
decimals, depthvalue, depth_unit, decimals, depthvalue, depth_unit,
FRACTION(dp->time - lasttime, 60), FRACTION(dp->time - lasttime, 60),
@ -582,15 +582,17 @@ static void add_plan_to_notes(struct diveplan *diveplan, struct dive *dive, bool
lasttime = dp->time; lasttime = dp->time;
} }
} else { } else {
len += snprintf(buffer + len, sizeof(buffer) - len, translate("gettextFromC", "Stay at %.*f %s for %d:%02d min - runtime %d:%02u on %s<br>"), if (dp->depth != nextdp->depth) {
decimals, depthvalue, depth_unit, len += snprintf(buffer + len, sizeof(buffer) - len, translate("gettextFromC", "Stay at %.*f %s for %d:%02d min - runtime %d:%02u on %s<br>"),
FRACTION(dp->time - lasttime, 60), decimals, depthvalue, depth_unit,
FRACTION(dp->time, 60), FRACTION(dp->time - lasttime, 60),
gasname(&gasmix)); FRACTION(dp->time, 60),
lasttime = dp->time; gasname(&gasmix));
lasttime = dp->time;
}
} }
} else { } else {
if (dp->depth == lastdepth || plan_display_transitions || dp->entered || !dp->next || (gaschange && dp->next && (dp->depth != dp->next->depth || !dp->next->time))) { if ((dp->depth == lastdepth && dp->depth != nextdp->depth) || plan_display_transitions || dp->entered || !dp->next || (gaschange && dp->next && dp->depth != nextdp->depth)) {
len += snprintf(buffer + len, sizeof(buffer) - len, translate("gettextFromC", "<tr><td align=right>%3.0f%s</td>"), depthvalue, depth_unit); len += snprintf(buffer + len, sizeof(buffer) - len, translate("gettextFromC", "<tr><td align=right>%3.0f%s</td>"), depthvalue, depth_unit);
if (plan_display_runtime) if (plan_display_runtime)
len += snprintf(buffer + len, sizeof(buffer) - len, translate("gettextFromC", " <td align=right>%3dmin</td> "), (dp->time + 30) / 60); len += snprintf(buffer + len, sizeof(buffer) - len, translate("gettextFromC", " <td align=right>%3dmin</td> "), (dp->time + 30) / 60);
@ -615,7 +617,7 @@ static void add_plan_to_notes(struct diveplan *diveplan, struct dive *dive, bool
gasmix = newgasmix; gasmix = newgasmix;
} }
lastdepth = dp->depth; lastdepth = dp->depth;
} while ((dp = dp->next) != NULL); } while ((dp = nextdp) != NULL);
len = strlen(buffer); len = strlen(buffer);
snprintf(buffer + len, sizeof(buffer) - len, translate("gettextFromC", "</tbody></table><br>Gas consumption:<br>")); snprintf(buffer + len, sizeof(buffer) - len, translate("gettextFromC", "</tbody></table><br>Gas consumption:<br>"));
for (gasidx = 0; gasidx < MAX_CYLINDERS; gasidx++) { for (gasidx = 0; gasidx < MAX_CYLINDERS; gasidx++) {