mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +00:00
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>
This commit is contained in:
parent
ff40afc1d8
commit
7cfe1639b5
1 changed files with 5 additions and 4 deletions
|
@ -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),
|
||||
|
|
Loading…
Add table
Reference in a new issue