mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +00:00
Don't use negative gas index
This shouldn't happen, but in case we run out of gases we shouldn't use the negative gas index (which is the error return of get_gas_idx()) for the array. Let's fall back to the (incorrect) first gas. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
parent
d24d2288f3
commit
396106e307
1 changed files with 4 additions and 0 deletions
|
@ -161,6 +161,10 @@ static int time_at_last_depth(struct dive *dive, int o2, int he, unsigned int ne
|
||||||
sample = &dive->dc.sample[dive->dc.samples - 1];
|
sample = &dive->dc.sample[dive->dc.samples - 1];
|
||||||
depth = sample->depth.mm;
|
depth = sample->depth.mm;
|
||||||
gasidx = get_gasidx(dive, o2, he);
|
gasidx = get_gasidx(dive, o2, he);
|
||||||
|
if (gasidx == -1) {
|
||||||
|
fprintf(stderr, "cannot find gas (%d/%d), using first gas\n", o2, he);
|
||||||
|
gasidx = 0;
|
||||||
|
}
|
||||||
while (deco_allowed_depth(tissue_tolerance, surface_pressure, dive, 1) > next_stop) {
|
while (deco_allowed_depth(tissue_tolerance, surface_pressure, dive, 1) > next_stop) {
|
||||||
wait++;
|
wait++;
|
||||||
tissue_tolerance = add_segment(depth_to_mbar(depth, dive) / 1000.0,
|
tissue_tolerance = add_segment(depth_to_mbar(depth, dive) / 1000.0,
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue