diff options
author | Dirk Hohndel <dirk@hohndel.org> | 2013-02-12 20:58:58 -0800 |
---|---|---|
committer | Dirk Hohndel <dirk@hohndel.org> | 2013-02-12 21:12:17 -0800 |
commit | 5e93469f35106010b427ce24e0a9d0156b49a737 (patch) | |
tree | c99ed797ffb97a97f09ba4212730e5e25b263853 /dive.h | |
parent | 1b548c071b50a8576e0a23125b95748c42d6d0ef (diff) | |
download | subsurface-5e93469f35106010b427ce24e0a9d0156b49a737.tar.gz |
Fix gas handling in planner
Two separate bugs.
a) Air cylinders were created with o2=209 and no other value set.
sanitize_gasmix() turned that into o2=0 which meant that this cylinder was
now identified as "nodata", i.e., unset.
We now set a fake cylinder name to deal with that issue.
b) the gaschange event is inherited from libdivecomputer and therefore
only supports 1 percent granularity for o2 and h2. Since we didn't round
when assigning the value we ended up with air being stored as o2=20 he=0
which of course then didn't match air anymore (which we have defined as
208 <= o2 <= 210).
We now use o2=210 for air in the planner and carefully round the permille
values whenever we convert into percent - and compare gases with percent
granularity as well.
A better fix for b) would be to change the Subsurface event to not simply
copy the libdivecomputer behavior and use percent granularity but support
permille instead. But this closely before the 3.0 release that seemed like
a far too invasive change to make - the changes to the planner should have
no impact outside the planner module.
Reported-by: Chris Lewis <chrislewis915@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Diffstat (limited to 'dive.h')
-rw-r--r-- | dive.h | 5 |
1 files changed, 5 insertions, 0 deletions
@@ -213,6 +213,11 @@ static inline int mbar_to_PSI(int mbar) return to_PSI(p); } +static inline gboolean is_air(int o2, int he) +{ + return (he == 0) && (o2 == 0 || ((o2 >= O2_IN_AIR - 1) && (o2 <= O2_IN_AIR + 1))); +} + /* Linear interpolation between 'a' and 'b', when we are 'part'way into the 'whole' distance from a to b */ static inline int interpolate(int a, int b, int part, int whole) { |