summaryrefslogtreecommitdiffstats
path: root/core/divelist.c
diff options
context:
space:
mode:
authorGravatar Willem Ferguson <willemferguson@zoology.up.ac.za>2018-04-03 19:30:27 +0200
committerGravatar Lubomir I. Ivanov <neolit123@gmail.com>2018-05-14 23:47:00 +0300
commit27a0542220ae3766f0a98058c28e86d6c6d43a62 (patch)
treecf5a13544588d53667c2a4272a9053406b32d6a6 /core/divelist.c
parentcf377beb2ea13833fa4a867b9c99153ecd9fff22 (diff)
downloadsubsurface-27a0542220ae3766f0a98058c28e86d6c6d43a62.tar.gz
Implement bailout outside of the dive planner
This is the second step for implementing bailout. The indirect calls to fill_pressures through add_segment() (in deco.c) are addressed. Bailout is now fully implemented in the dive log but not in the dive planner. 1) The parameters to add_segment() are changed to take a divemode as the second last parameter, and not a *dive. 2) Call to add_segment() in profile.c and in divelist.c are adapted. In divelist.c some calls to add_segment were left using dc-> divemode instead of possible bailout. This appears tp be the most appropriate route. 3) The functions get_divemode_from_time() and get_next_divemodechange() in dive.c have had some small changes. 4) The calls to get_segment(0 in planner.c were changed to reflect the new parameter list, but not updated to reflect bailout. This is the next step. Signed-off-by: Willem Ferguson <willemferguson@zoology.up.ac.za>
Diffstat (limited to 'core/divelist.c')
-rw-r--r--core/divelist.c8
1 files changed, 5 insertions, 3 deletions
diff --git a/core/divelist.c b/core/divelist.c
index caa659527..c79cb56b5 100644
--- a/core/divelist.c
+++ b/core/divelist.c
@@ -415,6 +415,7 @@ static void add_dive_to_deco(struct deco_state *ds, struct dive *dive)
struct divecomputer *dc = &dive->dc;
struct gasmix *gasmix = NULL;
struct event *ev = NULL;
+ struct event *ev_dmc = dc->events, *ev_dmt = get_next_divemodechange(&ev_dmc);
int i;
if (!dc)
@@ -430,7 +431,8 @@ static void add_dive_to_deco(struct deco_state *ds, struct dive *dive)
for (j = t0; j < t1; j++) {
int depth = interpolate(psample->depth.mm, sample->depth.mm, j - t0, t1 - t0);
gasmix = get_gasmix(dive, dc, j, &ev, gasmix);
- add_segment(ds, depth_to_bar(depth, dive), gasmix, 1, sample->setpoint.mbar, dive, dive->sac);
+ add_segment(ds, depth_to_bar(depth, dive), gasmix, 1, sample->setpoint.mbar,
+ get_divemode_at_time(dc, j, &ev_dmt), dive->sac);
}
}
}
@@ -584,7 +586,7 @@ int init_decompression(struct deco_state *ds, struct dive *dive)
#endif
return surface_time;
}
- add_segment(ds, surface_pressure, &air, surface_time, 0, dive, prefs.decosac);
+ add_segment(ds, surface_pressure, &air, surface_time, 0, dive->dc.divemode, prefs.decosac);
#if DECO_CALC_DEBUG & 2
printf("Tissues after surface intervall of %d:%02u:\n", FRACTION(surface_time, 60));
dump_tissues(ds);
@@ -622,7 +624,7 @@ int init_decompression(struct deco_state *ds, struct dive *dive)
#endif
return surface_time;
}
- add_segment(ds, surface_pressure, &air, surface_time, 0, dive, prefs.decosac);
+ add_segment(ds, surface_pressure, &air, surface_time, 0, dive->dc.divemode, prefs.decosac);
#if DECO_CALC_DEBUG & 2
printf("Tissues after surface intervall of %d:%02u:\n", FRACTION(surface_time, 60));
dump_tissues(ds);