aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar Robert C. Helling <helling@atdotde.de>2017-02-07 09:18:19 +0100
committerGravatar Dirk Hohndel <dirk@hohndel.org>2017-02-10 06:41:24 -0800
commit032c3258edc875ea39ce3124a40e23a22bd6ffe7 (patch)
tree0a5774ebe674b4d22f9662b500a0e0a9dcf1e5fe
parentec20d36f3c895abfb68320176e8b23b9b90b6e2c (diff)
downloadsubsurface-032c3258edc875ea39ce3124a40e23a22bd6ffe7.tar.gz
Reset VPM-B state between repetitive dives
This resets the maximum crushing pressures and the maximal ambient pressure between repetitive dives to prevent anomalies that a dive produces a shorter deco when following another one than without. Reported-by: sfuchs@gmx.de Signed-off-by: Robert C. Helling <helling@atdotde.de> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
-rw-r--r--core/deco.c10
-rw-r--r--core/dive.h1
-rw-r--r--core/divelist.c1
3 files changed, 12 insertions, 0 deletions
diff --git a/core/deco.c b/core/deco.c
index dd5cfa056..5014f1b61 100644
--- a/core/deco.c
+++ b/core/deco.c
@@ -559,9 +559,19 @@ void dump_tissues()
printf("\n");
}
+void clear_vpmb_state() {
+ int ci;
+ for (ci = 0; ci < 16; ci++) {
+ max_n2_crushing_pressure[ci] = 0.0;
+ max_he_crushing_pressure[ci] = 0.0;
+ }
+ max_ambient_pressure = 0;
+}
+
void clear_deco(double surface_pressure)
{
int ci;
+ clear_vpmb_state();
for (ci = 0; ci < 16; ci++) {
tissue_n2_sat[ci] = (surface_pressure - ((in_planner() && (decoMode() == VPMB)) ? WV_PRESSURE_SCHREINER : WV_PRESSURE)) * N2_IN_AIR / 1000;
tissue_he_sat[ci] = 0.0;
diff --git a/core/dive.h b/core/dive.h
index 1b99fc376..4608e9d71 100644
--- a/core/dive.h
+++ b/core/dive.h
@@ -872,6 +872,7 @@ void dump_plan(struct diveplan *diveplan);
bool plan(struct diveplan *diveplan, char **cached_datap, bool is_planner, bool show_disclaimer);
void calc_crushing_pressure(double pressure);
void vpmb_start_gradient();
+void clear_vpmb_state();
void delete_single_dive(int idx);
diff --git a/core/divelist.c b/core/divelist.c
index b28dd5ef3..44401b7c0 100644
--- a/core/divelist.c
+++ b/core/divelist.c
@@ -423,6 +423,7 @@ unsigned int init_decompression(struct dive *dive)
}
add_dive_to_deco(pdive);
laststart = pdive->when;
+ clear_vpmb_state();
#if DECO_CALC_DEBUG & 2
printf("added dive #%d\n", pdive->number);
dump_tissues();