summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar Robert C. Helling <helling@atdotde.de>2018-04-27 20:14:07 +0200
committerGravatar Lubomir I. Ivanov <neolit123@gmail.com>2018-05-14 23:47:00 +0300
commit09da42f8192a83dba0b7b31b78b5c40100e164b1 (patch)
treefb84f2ddbd75a98a6d68ca8870b5138e4b1bc0e8
parent5bac32a1b57862579d15e70ce1c5f1e8adab59b8 (diff)
downloadsubsurface-09da42f8192a83dba0b7b31b78b5c40100e164b1.tar.gz
Fix divemode detection in planner
Signed-off-by: Robert C. Helling <helling@atdotde.de>
-rw-r--r--core/dive.c5
-rw-r--r--core/planner.c3
2 files changed, 3 insertions, 5 deletions
diff --git a/core/dive.c b/core/dive.c
index d75de418e..9ec95c141 100644
--- a/core/dive.c
+++ b/core/dive.c
@@ -250,11 +250,10 @@ enum dive_comp_type get_current_divemode(struct divecomputer *dc, int time, stru
struct event *ev = *evp;
if (*divemode == UNDEF_COMP_TYPE) {
*divemode = dc->divemode;
- ev = dc ? dc->events : NULL;
+ ev = dc ? get_next_event(dc->events, "modechange") : NULL;
}
while (ev && ev->time.seconds < time) {
- if (ev != dc->events)
- *divemode = (enum dive_comp_type) ev->value;
+ *divemode = (enum dive_comp_type) ev->value;
ev = get_next_event(ev->next, "modechange");
}
*evp = ev;
diff --git a/core/planner.c b/core/planner.c
index 51b3a487b..40424cc61 100644
--- a/core/planner.c
+++ b/core/planner.c
@@ -190,7 +190,7 @@ int tissue_at_end(struct deco_state *ds, struct dive *dive, struct deco_state **
ds->max_bottom_ceiling_pressure.mbar = ceiling_pressure.mbar;
}
- divemode = get_current_divemode(&dive->dc, t0.seconds, &evdm, &divemode);
+ divemode = get_current_divemode(&dive->dc, t0.seconds + 1, &evdm, &divemode);
interpolate_transition(ds, dive, t0, t1, lastdepth, sample->depth, &gas, setpoint, divemode);
psample = sample;
t0 = t1;
@@ -367,7 +367,6 @@ static void create_dive_from_plan(struct diveplan *diveplan, struct dive *dive,
}
dive->dc.last_manual_time.seconds = last_manual_point;
- dc->divemode = type;
#if DEBUG_PLAN & 32
save_dive(stdout, &displayed_dive);
#endif