mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +00:00
Planner: pass dive to enough_gas()
Enough gas was checking the currently displayed dive instead of the dive to be planned. Not good in a multi-threaded context. Pass the actual dive instead. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
This commit is contained in:
parent
7cfe1639b5
commit
e921715410
1 changed files with 3 additions and 4 deletions
|
@ -595,10 +595,9 @@ static bool trial_ascent(struct deco_state *ds, int wait_time, int trial_depth,
|
|||
* Also return true if this cannot be calculated because the cylinder doesn't have
|
||||
* size or a starting pressure.
|
||||
*/
|
||||
static bool enough_gas(int current_cylinder)
|
||||
static bool enough_gas(const struct dive *dive, int current_cylinder)
|
||||
{
|
||||
cylinder_t *cyl;
|
||||
cyl = &displayed_dive.cylinder[current_cylinder];
|
||||
const cylinder_t *cyl = &dive->cylinder[current_cylinder];
|
||||
|
||||
if (!cyl->start.mbar)
|
||||
return true;
|
||||
|
@ -793,7 +792,7 @@ bool plan(struct deco_state *ds, struct diveplan *diveplan, struct dive *dive, i
|
|||
clock += timestep;
|
||||
} while (trial_ascent(ds, 0, depth, 0, avg_depth, bottom_time, dive->cylinder[current_cylinder].gasmix,
|
||||
po2, diveplan->surface_pressure / 1000.0, dive, divemode) &&
|
||||
enough_gas(current_cylinder) && clock < 6 * 3600);
|
||||
enough_gas(dive, current_cylinder) && clock < 6 * 3600);
|
||||
|
||||
// We did stay one DECOTIMESTEP too many.
|
||||
// In the best of all worlds, we would roll back also the last add_segment in terms of caching deco state, but
|
||||
|
|
Loading…
Add table
Reference in a new issue