mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +00:00
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>
This commit is contained in:
parent
1b548c071b
commit
5e93469f35
3 changed files with 44 additions and 18 deletions
2
dive.c
2
dive.c
|
|
@ -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;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue