diff options
author | Berthold Stoeger <bstoeger@mail.tuwien.ac.at> | 2021-02-12 17:39:46 +0100 |
---|---|---|
committer | Dirk Hohndel <dirk@hohndel.org> | 2021-02-17 07:26:55 -0800 |
commit | 93ecad1b0413645ba59ffe2e50c3636d8673ccb5 (patch) | |
tree | c6b7d2aef7fd8aafa2a0570ca1ffa3168d85f736 /core/divelist.c | |
parent | 9fb37ea27f757c76324f9a101a54133cedd71922 (diff) | |
download | subsurface-93ecad1b0413645ba59ffe2e50c3636d8673ccb5.tar.gz |
planner: pass in_planner argument to add_segment()
To remove reliance on global state, pass an "in_planner" argument
to add_segment(). Thus, calls to in_planner() can be removed.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Diffstat (limited to 'core/divelist.c')
-rw-r--r-- | core/divelist.c | 13 |
1 files changed, 7 insertions, 6 deletions
diff --git a/core/divelist.c b/core/divelist.c index fc02dac45..583451e8f 100644 --- a/core/divelist.c +++ b/core/divelist.c @@ -372,7 +372,7 @@ static int calculate_sac(const struct dive *dive) } /* for now we do this based on the first divecomputer */ -static void add_dive_to_deco(struct deco_state *ds, struct dive *dive) +static void add_dive_to_deco(struct deco_state *ds, struct dive *dive, bool in_planner) { struct divecomputer *dc = &dive->dc; struct gasmix gasmix = gasmix_air; @@ -394,7 +394,8 @@ static void add_dive_to_deco(struct deco_state *ds, struct dive *dive) 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, - get_current_divemode(&dive->dc, j, &evd, ¤t_divemode), dive->sac); + get_current_divemode(&dive->dc, j, &evd, ¤t_divemode), dive->sac, + in_planner); } } } @@ -419,7 +420,7 @@ static struct gasmix air = { .o2.permille = O2_IN_AIR, .he.permille = 0 }; /* return negative surface time if dives are overlapping */ /* The place you call this function is likely the place where you want * to create the deco_state */ -int init_decompression(struct deco_state *ds, const struct dive *dive) +int init_decompression(struct deco_state *ds, const struct dive *dive, bool in_planner) { int i, divenr = -1; int surface_time = 48 * 60 * 60; @@ -534,14 +535,14 @@ int init_decompression(struct deco_state *ds, const struct dive *dive) #endif return surface_time; } - add_segment(ds, surface_pressure, air, surface_time, 0, dive->dc.divemode, prefs.decosac); + add_segment(ds, surface_pressure, air, surface_time, 0, dive->dc.divemode, prefs.decosac, in_planner); #if DECO_CALC_DEBUG & 2 printf("Tissues after surface intervall of %d:%02u:\n", FRACTION(surface_time, 60)); dump_tissues(ds); #endif } - add_dive_to_deco(ds, pdive); + add_dive_to_deco(ds, pdive, in_planner); last_starttime = pdive->when; last_endtime = dive_endtime(pdive); @@ -571,7 +572,7 @@ int init_decompression(struct deco_state *ds, const struct dive *dive) #endif return surface_time; } - add_segment(ds, surface_pressure, air, surface_time, 0, dive->dc.divemode, prefs.decosac); + add_segment(ds, surface_pressure, air, surface_time, 0, dive->dc.divemode, prefs.decosac, in_planner); #if DECO_CALC_DEBUG & 2 printf("Tissues after surface intervall of %d:%02u:\n", FRACTION(surface_time, 60)); dump_tissues(ds); |