Skip to content

Commit

Permalink
Improve gas accounting in the panner
Browse files Browse the repository at this point in the history
When using gasmixes where the difference is less than 2% the planner can't
caclulate casconsumptions correctly. This sets the minimum gasdifference
to 1%.

Fixes subsurface#795

Signed-off-by: Joakim Bygdell <j.bygdell@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
  • Loading branch information
jbygdell authored and dirkhh committed Mar 9, 2015
1 parent 237043d commit 20a82e2
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions planner.c
Expand Up @@ -115,7 +115,7 @@ int get_gasidx(struct dive *dive, struct gasmix *mix)
int gasidx = -1;

while (++gasidx < MAX_CYLINDERS)
if (gasmix_distance(&dive->cylinder[gasidx].gasmix, mix) < 200)
if (gasmix_distance(&dive->cylinder[gasidx].gasmix, mix) < 100)
return gasidx;
return -1;
}
Expand Down Expand Up @@ -210,7 +210,7 @@ static int verify_gas_exists(struct gasmix mix_in)
cyl = displayed_dive.cylinder + i;
if (cylinder_nodata(cyl))
continue;
if (gasmix_distance(&cyl->gasmix, &mix_in) < 200)
if (gasmix_distance(&cyl->gasmix, &mix_in) < 100)
return i;
}
fprintf(stderr, "this gas %s should have been on the cylinder list\nThings will fail now\n", gasname(&mix_in));
Expand Down
4 changes: 2 additions & 2 deletions qt-ui/diveplanner.cpp
Expand Up @@ -1112,7 +1112,7 @@ bool DivePlannerPointsModel::tankInUse(struct gasmix gasmix)
continue;
if (!p.entered) // removing deco gases is ok
continue;
if (gasmix_distance(&p.gasmix, &gasmix) < 200)
if (gasmix_distance(&p.gasmix, &gasmix) < 100)
return true;
}
return false;
Expand All @@ -1139,7 +1139,7 @@ void DivePlannerPointsModel::tanksUpdated()
struct gasmix gas;
gas.o2.permille = oldGases.at(i).first;
gas.he.permille = oldGases.at(i).second;
if (gasmix_distance(&gas, &p.gasmix) < 200) {
if (gasmix_distance(&gas, &p.gasmix) < 100) {
p.gasmix.o2.permille = gases.at(i).first;
p.gasmix.he.permille = gases.at(i).second;
}
Expand Down

0 comments on commit 20a82e2

Please sign in to comment.