aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
authorGravatar Tim Segers <tsegers@pm.me>2022-12-27 22:29:29 +0100
committerGravatar Tim Segers <tsegers@pm.me>2023-01-02 15:06:03 +0100
commitb98ef9a0cc52538a62f7f15d6ab28a2e98751c50 (patch)
tree8a78353b414ab8db74016357c5d46076bc7ff86b
parent5473e3119d03d079e81fec7a05edfb38c52e1342 (diff)
downloadopendeco-b98ef9a0cc52538a62f7f15d6ab28a2e98751c50.tar.gz
Fix error in waypoint duration calculation
-rw-r--r--src/schedule.c10
1 files 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;