summaryrefslogtreecommitdiffstats
path: root/core
diff options
context:
space:
mode:
authorGravatar Robert C. Helling <helling@atdotde.de>2016-06-08 21:51:02 +0200
committerGravatar Dirk Hohndel <dirk@hohndel.org>2016-06-11 10:28:04 -0700
commit3870916ae24cb3e5531792c3a7c990a11913fee7 (patch)
treef0dc7702909621b8359d68a4e165d69e7794cde2 /core
parent7a77569019adde1a623229baf52f30a9345d0616 (diff)
downloadsubsurface-3870916ae24cb3e5531792c3a7c990a11913fee7.tar.gz
Fix logic for presaturation
There were two problems in the calculation of tissue pre- saturation from previous dives: We added the surface interval after the dive rather than before and when also took dives into accout that were in the future of the dive considerd. Reported-by: Timothy Massey Signed-off-by: Robert C. Helling <helling@atdotde.de> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Diffstat (limited to 'core')
-rw-r--r--core/divelist.c15
1 files changed, 9 insertions, 6 deletions
diff --git a/core/divelist.c b/core/divelist.c
index 1ac19bd3f..fa100c236 100644
--- a/core/divelist.c
+++ b/core/divelist.c
@@ -400,6 +400,9 @@ double init_decompression(struct dive *dive)
/* again skip dives from different trips */
if (dive->divetrip && dive->divetrip != pdive->divetrip)
continue;
+ /* Don't add future dives */
+ if (pdive->when > dive->when)
+ continue; /* This could be break if the divelist is always sorted */
surface_pressure = get_surface_pressure_in_mbar(pdive, true) / 1000.0;
if (!deco_init) {
clear_deco(surface_pressure);
@@ -408,12 +411,6 @@ double init_decompression(struct dive *dive)
dump_tissues();
#endif
}
- add_dive_to_deco(pdive);
- laststart = pdive->when;
-#if DECO_CALC_DEBUG & 2
- printf("added dive #%d\n", pdive->number);
- dump_tissues();
-#endif
if (pdive->when > lasttime) {
surface_time = pdive->when - lasttime;
lasttime = pdive->when + pdive->duration.seconds;
@@ -423,6 +420,12 @@ double init_decompression(struct dive *dive)
dump_tissues();
#endif
}
+ add_dive_to_deco(pdive);
+ laststart = pdive->when;
+#if DECO_CALC_DEBUG & 2
+ printf("added dive #%d\n", pdive->number);
+ dump_tissues();
+#endif
}
/* add the final surface time */
if (lasttime && dive->when > lasttime) {