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 <helling@atdotde.de>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
Robert C. Helling 2015-08-03 17:29:05 +02:00 committed by Dirk Hohndel
parent abbebef997
commit e79cae577d

View file

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