From 80a2cd7b1bf6df00adf84a13b1e6f16910a0bdeb Mon Sep 17 00:00:00 2001 From: Stefan Fuchs Date: Mon, 9 Oct 2017 23:38:38 +0200 Subject: 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 --- core/planner.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'core/planner.c') 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; } -- cgit v1.2.3-70-g09d2