diff options
author | Berthold Stoeger <bstoeger@mail.tuwien.ac.at> | 2019-08-06 11:33:01 +0200 |
---|---|---|
committer | Dirk Hohndel <dirk@hohndel.org> | 2019-08-08 16:26:31 -0700 |
commit | 7cfe1639b5874ad7243bcbe5781ae0c6ae6adf4b (patch) | |
tree | d2242888afdf31060cd428d3c9b35b97c01ee90c /core/planner.c | |
parent | ff40afc1d86789c988d6bce33af9995646f0e963 (diff) | |
download | subsurface-7cfe1639b5874ad7243bcbe5781ae0c6ae6adf4b.tar.gz |
Planner: pass dive / cylinder pair to track_ascent_gas()
Pass the dive to be planned to track_ascent_gas and don't use
the displayed_dive. For convenience, pass the cylinder-id, since
the function can now access the cylinder of the dive by itself.
This makes the callers less verbose.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Diffstat (limited to 'core/planner.c')
-rw-r--r-- | core/planner.c | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/core/planner.c b/core/planner.c index dd7c98ca6..fd6c13604 100644 --- a/core/planner.c +++ b/core/planner.c @@ -527,15 +527,16 @@ int ascent_velocity(int depth, int avg_depth, int bottom_time) } } -static void track_ascent_gas(int depth, cylinder_t *cylinder, int avg_depth, int bottom_time, bool safety_stop, enum divemode_t divemode) +static void track_ascent_gas(int depth, struct dive *dive, int cylinder_id, int avg_depth, int bottom_time, bool safety_stop, enum divemode_t divemode) { + cylinder_t *cylinder = &dive->cylinder[cylinder_id]; while (depth > 0) { int deltad = ascent_velocity(depth, avg_depth, bottom_time) * TIMESTEP; if (deltad > depth) deltad = depth; - update_cylinder_pressure(&displayed_dive, depth, depth - deltad, TIMESTEP, prefs.decosac, cylinder, true, divemode); + update_cylinder_pressure(dive, depth, depth - deltad, TIMESTEP, prefs.decosac, cylinder, true, divemode); if (depth <= 5000 && depth >= (5000 - deltad) && safety_stop) { - update_cylinder_pressure(&displayed_dive, 5000, 5000, 180, prefs.decosac, cylinder, true, divemode); + update_cylinder_pressure(dive, 5000, 5000, 180, prefs.decosac, cylinder, true, divemode); safety_stop = false; } depth -= deltad; @@ -782,7 +783,7 @@ bool plan(struct deco_state *ds, struct diveplan *diveplan, struct dive *dive, i vpmb_start_gradient(ds); if (decoMode() == RECREATIONAL) { bool safety_stop = prefs.safetystop && max_depth >= 10000; - track_ascent_gas(depth, &dive->cylinder[current_cylinder], avg_depth, bottom_time, safety_stop, divemode); + track_ascent_gas(depth, dive, current_cylinder, avg_depth, bottom_time, safety_stop, divemode); // How long can we stay at the current depth and still directly ascent to the surface? do { add_segment(ds, depth_to_bar(depth, dive), |