aboutsummaryrefslogtreecommitdiffstats
path: root/divelist.c
diff options
context:
space:
mode:
authorGravatar Linus Torvalds <torvalds@linux-foundation.org>2011-11-09 07:51:00 -0800
committerGravatar Linus Torvalds <torvalds@linux-foundation.org>2011-11-09 08:16:49 -0800
commitc32cff2c6be74a6284f940328622740953008020 (patch)
treef6a92a5f42ce02396a60b8f857201190c3055823 /divelist.c
parent0089dd8819b7b28ad5c48dbfc881f4011f18014e (diff)
downloadsubsurface-c32cff2c6be74a6284f940328622740953008020.tar.gz
Fix up air use calculations for new pressure handling
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>
Diffstat (limited to 'divelist.c')
-rw-r--r--divelist.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/divelist.c b/divelist.c
index 2d04eb5b0..eb8f23143 100644
--- a/divelist.c
+++ b/divelist.c
@@ -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;