]> git.tdb.fi Git - ext/subsurface.git/commitdiff
Fix up air use calculations for new pressure handling
authorLinus Torvalds <torvalds@linux-foundation.org>
Wed, 9 Nov 2011 15:51:00 +0000 (07:51 -0800)
committerLinus Torvalds <torvalds@linux-foundation.org>
Wed, 9 Nov 2011 16:16:49 +0000 (08:16 -0800)
Make sure that we calculate air use by using the proper start/end
pressures, with the manually set ones being used preferentially over any
possible sample data.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
divelist.c

index 2d04eb5b09e4469f13ad5029b6838294497a6d2a..eb8f231432a99f33f40a8ca0341aee8a66b14148 100644 (file)
@@ -299,6 +299,7 @@ static double calculate_airuse(struct dive *dive)
        int i;
 
        for (i = 0; i < MAX_CYLINDERS; i++) {
+               pressure_t start, end;
                cylinder_t *cyl = dive->cylinder + i;
                int size = cyl->type.size.mliter;
                double kilo_atm;
@@ -306,7 +307,9 @@ static double calculate_airuse(struct dive *dive)
                if (!size)
                        continue;
 
-               kilo_atm = (to_ATM(cyl->start) - to_ATM(cyl->end)) / 1000.0;
+               start = cyl->start.mbar ? cyl->start : cyl->sample_start;
+               end = cyl->end.mbar ? cyl->end : cyl->sample_end;
+               kilo_atm = (to_ATM(start) - to_ATM(end)) / 1000.0;
 
                /* Liters of air at 1 atm == milliliters at 1k atm*/
                airuse += kilo_atm * size;