From b98ef9a0cc52538a62f7f15d6ab28a2e98751c50 Mon Sep 17 00:00:00 2001 From: Tim Segers Date: Tue, 27 Dec 2022 22:29:29 +0100 Subject: Fix error in waypoint duration calculation --- src/schedule.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/schedule.c b/src/schedule.c index 56349fc..5528ce3 100644 --- a/src/schedule.c +++ b/src/schedule.c @@ -147,11 +147,11 @@ decoinfo_t calc_deco(decostate_t *ds, double start_depth, const gas_t *start_gas double current_gf = get_gf(ds, next_stop); - for (;;) { - /* extra bookkeeping because waypoints and segments do not match 1:1 */ - double last_waypoint_depth = depth; - double waypoint_time; + /* extra bookkeeping because waypoints and segments do not match 1:1 */ + double last_waypoint_depth = depth; + double waypoint_time; + for (;;) { while (ceiling(ds, current_gf) < next_stop && !surfaced(depth)) { /* switch to better gas if available */ const gas_t *best = best_gas(depth, deco_gasses, nof_gasses); @@ -212,6 +212,8 @@ decoinfo_t calc_deco(decostate_t *ds, double start_depth, const gas_t *start_gas if (wp_cb && wp_cb->fn && waypoint_time) wp_cb->fn(ds, (waypoint_t){.depth = depth, .time = waypoint_time, .gas = gas}, segtype, wp_cb->arg); + last_waypoint_depth = depth; + /* terminate if we surfaced */ if (surfaced(depth)) return ret; -- cgit v1.2.3-70-g09d2