aboutsummaryrefslogtreecommitdiffstats
path: root/core/divelist.c
diff options
context:
space:
mode:
authorGravatar Robert C. Helling <helling@atdotde.de>2018-05-17 21:25:57 +0200
committerGravatar Robert C. Helling <helling@atdotde.de>2018-05-28 09:57:00 +0200
commitfb09784060a10ef181e20d8e3adc3d7b1c55041e (patch)
tree1a02b5691a6f92bee57e858a7d9338d597d6c638 /core/divelist.c
parenteb52f36cb69d80a5024a94a4996f5426bd16c27a (diff)
downloadsubsurface-fb09784060a10ef181e20d8e3adc3d7b1c55041e.tar.gz
Don't compute SAC if total gas use is unknown
If we breathe from a cylinder with invalid start or end pressures, we cannot reliably compute the total gas use and thus the SAC. So we should not pretend to do so. A better fix would compute the total SAC for only those segements that have valid start and end pressures. Reported-by: Stefan Fuchs <sfuchs@gmx.de> Signed-off-by: Robert C. Helling <helling@atdotde.de>
Diffstat (limited to 'core/divelist.c')
-rw-r--r--core/divelist.c12
1 files changed, 10 insertions, 2 deletions
diff --git a/core/divelist.c b/core/divelist.c
index d5dc37271..6986c5a80 100644
--- a/core/divelist.c
+++ b/core/divelist.c
@@ -374,8 +374,16 @@ static double calculate_airuse(struct dive *dive)
start = cyl->start.mbar ? cyl->start : cyl->sample_start;
end = cyl->end.mbar ? cyl->end : cyl->sample_end;
- if (!end.mbar || start.mbar <= end.mbar)
- continue;
+ if (!end.mbar || start.mbar <= end.mbar) {
+ // If a cylinder is used but we do not have info on amout of gas used
+ // better not pretend we know the total gas use.
+ // Eventually, logic should be fixed to compute average depth and total time
+ // for those segments where cylinders with known pressure drop are breathed from.
+ if (is_cylinder_used(dive, i))
+ return 0.0;
+ else
+ continue;
+ }
airuse += gas_volume(cyl, start) - gas_volume(cyl, end);
}