From 8bdb7dbc1c52f07a48da4719db6164b76587ea65 Mon Sep 17 00:00:00 2001 From: "Robert C. Helling" Date: Mon, 3 Aug 2015 17:29:05 +0200 Subject: [PATCH] Decrease gaschange index even if we are already breathing the new mix This fixes a bug where we would not do any gas changes at all if at the end of bottom time we were deeper than the MOD of the bottom mix. Instead we would constantly try to switch to that gas and find we are already breathing it. A test case would be a dive with air and EAN50 to more than 66m. That would have never switched to EAN50. Signed-off-by: Robert C. Helling --- planner.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/planner.c b/planner.c index 377b868..3d7587d 100644 --- a/planner.c +++ b/planner.c @@ -1142,6 +1142,7 @@ bool plan(struct diveplan *diveplan, char **cached_datap, bool is_planner, bool * We might not if the cylinder was chosen by the user * or user has selected only to switch only at required stops. * If current gas is hypoxic, we want to switch asap */ + if (current_cylinder != gaschanges[gi].gasidx) { if (!prefs.switch_at_req_stop || !trial_ascent(depth, stoplevels[stopidx - 1], avg_depth, bottom_time, tissue_tolerance, @@ -1165,8 +1166,8 @@ bool plan(struct diveplan *diveplan, char **cached_datap, bool is_planner, bool */ pendinggaschange = true; } - gi--; } + gi--; } --stopidx; -- 2.3.2 (Apple Git-55)