diff options
author | Berthold Stoeger <bstoeger@mail.tuwien.ac.at> | 2019-08-06 11:35:56 +0200 |
---|---|---|
committer | Dirk Hohndel <dirk@hohndel.org> | 2019-08-08 16:26:31 -0700 |
commit | e921715410b6ea363172170f5750f1db1bbc5441 (patch) | |
tree | 885934d914b164d725e845a22b4dae87f52f595a /core/planner.c | |
parent | 7cfe1639b5874ad7243bcbe5781ae0c6ae6adf4b (diff) | |
download | subsurface-e921715410b6ea363172170f5750f1db1bbc5441.tar.gz |
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>
Diffstat (limited to 'core/planner.c')
-rw-r--r-- | core/planner.c | 7 |
1 files changed, 3 insertions, 4 deletions
diff --git a/core/planner.c b/core/planner.c index fd6c13604..2ce001d39 100644 --- a/core/planner.c +++ b/core/planner.c @@ -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 |