X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=divelist.c;h=32dc92b9980dc7bf75573c0880a84e069927b871;hb=2175226580a523a9a3abba3723991b003eee5a2a;hp=86e7daf571052104710ce8060ace9af34c11a17f;hpb=e5b6bfc7ed03bb6649abcfbac79f06aafd235918;p=ext%2Fsubsurface.git diff --git a/divelist.c b/divelist.c index 86e7daf..32dc92b 100644 --- a/divelist.c +++ b/divelist.c @@ -392,8 +392,10 @@ static int calculate_otu(struct dive *dive) struct sample *sample = dive->sample + i; struct sample *psample = sample - 1; t = sample->time.seconds - psample->time.seconds; - po2 = dive->cylinder[sample->cylinderindex].gasmix.o2.permille / 1000.0 * - (sample->depth.mm + 10000) / 10000.0; + int o2 = dive->cylinder[sample->cylinderindex].gasmix.o2.permille; + if (!o2) + o2 = 209; + po2 = o2 / 1000.0 * (sample->depth.mm + 10000) / 10000.0; if (po2 >= 0.5) otu += pow(po2 - 0.5, 0.83) * t / 30.0; }