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>
This commit is contained in:
Stefan Fuchs 2017-10-09 23:38:38 +02:00 committed by Robert C. Helling
parent 24bd5a8dce
commit 80a2cd7b1b

View file

@ -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;
}