Fix interpretation of dive mode changes upon replan

... by taking into acount that dive planner points refer
to the sement before the waypoint (while change mode
events are concerned with the future of a waypoint).

Signed-off-by: Robert C. Helling <helling@atdotde.de>
This commit is contained in:
Robert C. Helling 2018-06-17 23:21:53 +02:00
parent 4157365c96
commit 8406cbf187
2 changed files with 3 additions and 4 deletions

View file

@ -303,8 +303,6 @@ static void create_dive_from_plan(struct diveplan *diveplan, struct dive *dive,
lastcylid = 0;
while (dp) {
int po2 = dp->setpoint;
if (dp->setpoint)
type = CCR;
int time = dp->time;
depth_t depth = dp->depth;

View file

@ -115,9 +115,10 @@ void DivePlannerPointsModel::loadFromDive(dive *d)
break;
while (j * plansamples <= i * dc->samples) {
const sample &s = dc->sample[j];
const sample &prev = dc->sample[j-1];
if (s.time.seconds != 0 && (!hasMarkedSamples || s.manually_entered)) {
depthsum += s.depth.mm;
last_sp = s.setpoint;
last_sp = prev.setpoint;
++samplecount;
newtime = s.time;
}
@ -126,7 +127,7 @@ void DivePlannerPointsModel::loadFromDive(dive *d)
if (samplecount) {
cylinderid = get_cylinderid_at_time(d, dc, lasttime);
if (newtime.seconds - lastrecordedtime.seconds > 10) {
current_divemode = get_current_divemode(dc, newtime.seconds + 1, &evd, &current_divemode);
current_divemode = get_current_divemode(dc, newtime.seconds - 1, &evd, &current_divemode);
addStop(depthsum / samplecount, newtime.seconds, cylinderid, last_sp.mbar, true, current_divemode);
lastrecordedtime = newtime;
}