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.c | |
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.c')
-rw-r--r-- | dive.c | 2 |
1 files changed, 1 insertions, 1 deletions
@@ -281,7 +281,7 @@ static void sanitize_gasmix(struct gasmix *mix) if (!o2) return; /* 20.8% to 21% O2 is just air */ - if (o2 >= (O2_IN_AIR - 1) && o2 <= (O2_IN_AIR + 1)) { + if (is_air(o2, he)) { mix->o2.permille = 0; return; } |