diff options
author | Stefan Fuchs <sfuchs@gmx.de> | 2017-10-09 23:38:38 +0200 |
---|---|---|
committer | Robert C. Helling <helling@atdotde.de> | 2017-10-16 17:14:17 +0200 |
commit | 80a2cd7b1bf6df00adf84a13b1e6f16910a0bdeb (patch) | |
tree | 376e77909e5f5bda8c284c11224805cc306c0aa9 /core/planner.c | |
parent | 24bd5a8dcebec886b8fbbf077fabfb2106dc7dcd (diff) | |
download | subsurface-80a2cd7b1bf6df00adf84a13b1e6f16910a0bdeb.tar.gz |
Don't confuse cyl with same gasmix with best_first_ascend_gas
When calculating the dive plan in the planner don't accidently use
another gas with same gasmix instead of the gas stored as
"best_first_ascend_gas".
This is important if you have e.g. a bottom stage and back gas with
same gas mix because then you always want to start your ascent with
the gas you used in last entered dive planner point.
Signed-off-by: Stefan Fuchs <sfuchs@gmx.de>
Diffstat (limited to 'core/planner.c')
-rw-r--r-- | core/planner.c | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/core/planner.c b/core/planner.c index f53b9df2e..d823a0a39 100644 --- a/core/planner.c +++ b/core/planner.c @@ -867,7 +867,13 @@ bool plan(struct diveplan *diveplan, struct dive *dive, int timestep, struct dec deco_state->first_ceiling_pressure.mbar = deco_state->max_bottom_ceiling_pressure.mbar; last_ascend_rate = ascent_velocity(depth, avg_depth, bottom_time); - if ((current_cylinder = get_gasidx(dive, &gas)) == -1) { + /* Always prefer the best_first_ascend_cylinder if it has the right gasmix. + * Otherwise take first cylinder from list with rightgasmix */ + if (same_gasmix(&gas, &dive->cylinder[best_first_ascend_cylinder].gasmix)) + current_cylinder = best_first_ascend_cylinder; + else + current_cylinder = get_gasidx(dive, &gas); + if (current_cylinder == -1) { report_error(translate("gettextFromC", "Can't find gas %s"), gasname(&gas)); current_cylinder = 0; } |