summaryrefslogtreecommitdiffstats
path: root/planner.c
diff options
context:
space:
mode:
authorGravatar Robert C. Helling <helling@atdotde.de>2015-09-14 11:22:32 +0200
committerGravatar Dirk Hohndel <dirk@hohndel.org>2015-09-15 07:07:19 -0700
commit4a19145e04924cfb8460fec42ce54f352d433dd6 (patch)
tree6cba0aac85daadc99604d2c835ff2c674b78959c /planner.c
parent4d7338fd50bed89bf1bc286b05251f7ffe2ac286 (diff)
downloadsubsurface-4a19145e04924cfb8460fec42ce54f352d433dd6.tar.gz
Use the correct setpoint in planner
There is an unfortunate convention that the sample structure contains a setpoint at its end rather than during its duration which causes the expression sample[-1].setpoint in several places. This adds another one for the planner to use the correct setpoint during the manually entered leg of the dive. 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.c9
1 files changed, 8 insertions, 1 deletions
diff --git a/planner.c b/planner.c
index 2cf405404..a94aafbef 100644
--- a/planner.c
+++ b/planner.c
@@ -137,6 +137,13 @@ void tissue_at_end(struct dive *dive, char **cached_datap)
psample = sample = dc->sample;
for (i = 0; i < dc->samples; i++, sample++) {
+ o2pressure_t setpoint;
+
+ if (i)
+ setpoint = sample[-1].setpoint;
+ else
+ setpoint = sample[0].setpoint;
+
t1 = sample->time;
get_gas_at_time(dive, dc, t0, &gas);
if (i > 0)
@@ -165,7 +172,7 @@ void tissue_at_end(struct dive *dive, char **cached_datap)
max_bottom_ceiling_pressure.mbar = ceiling_pressure.mbar;
}
- interpolate_transition(dive, t0, t1, lastdepth, sample->depth, &gas, sample->setpoint);
+ interpolate_transition(dive, t0, t1, lastdepth, sample->depth, &gas, setpoint);
psample = sample;
t0 = t1;
}