summaryrefslogtreecommitdiffstats
path: root/core/deco.c
diff options
context:
space:
mode:
authorGravatar Robert C. Helling <helling@atdotde.de>2017-01-07 03:01:14 +0100
committerGravatar Subsurface <dirk@subsurface-divelog.org>2017-01-06 20:43:23 -0800
commitbb4bf639c333bee28d398c3670f52797d726b126 (patch)
treec28fe4eb2f51dc226931ee16e58edade6bf644ea /core/deco.c
parent4e375f56a8b15212b96e0ce5b7ca4724dc268612 (diff)
downloadsubsurface-bb4bf639c333bee28d398c3670f52797d726b126.tar.gz
Fix deco_mode confusion
We have two prefernces determining the deco_mode (BUEHLMANN vs VPMB vs RECREATIONAL): One for the planner (deco_mode) and one for displaying dives (display_deco_mode). The former is set in the planner settings while the latter is set in the preferences. This patch clears up a confusion which of the two to use by introducing a helper function that selects the correct variable. Signed-off-by: Robert C. Helling <helling@atdotde.de>
Diffstat (limited to 'core/deco.c')
-rw-r--r--core/deco.c11
1 files changed, 6 insertions, 5 deletions
diff --git a/core/deco.c b/core/deco.c
index a445c2539..dd5cfa056 100644
--- a/core/deco.c
+++ b/core/deco.c
@@ -21,6 +21,7 @@
#include "dive.h"
#include <assert.h>
#include "core/planner.h"
+#include "qthelperfromc.h"
#define cube(x) (x * x * x)
@@ -258,7 +259,7 @@ double tissue_tolerance_calc(const struct dive *dive, double pressure)
buehlmann_inertgas_b[ci] = ((buehlmann_N2_b[ci] * tissue_n2_sat[ci]) + (buehlmann_He_b[ci] * tissue_he_sat[ci])) / tissue_inertgas_saturation[ci];
}
- if (prefs.deco_mode != VPMB) {
+ if (decoMode() != VPMB) {
for (ci = 0; ci < 16; ci++) {
/* tolerated = (tissue_inertgas_saturation - buehlmann_inertgas_a) * buehlmann_inertgas_b; */
@@ -381,7 +382,7 @@ double he_factor(int period_in_seconds, int ci)
double calc_surface_phase(double surface_pressure, double he_pressure, double n2_pressure, double he_time_constant, double n2_time_constant)
{
- double inspired_n2 = (surface_pressure - ((in_planner() && (prefs.deco_mode == VPMB)) ? WV_PRESSURE_SCHREINER : WV_PRESSURE)) * NITROGEN_FRACTION;
+ double inspired_n2 = (surface_pressure - ((in_planner() && (decoMode() == VPMB)) ? WV_PRESSURE_SCHREINER : WV_PRESSURE)) * NITROGEN_FRACTION;
if (n2_pressure > inspired_n2)
return (he_pressure / he_time_constant + (n2_pressure - inspired_n2) / n2_time_constant) / (he_pressure + n2_pressure - inspired_n2);
@@ -522,7 +523,7 @@ void add_segment(double pressure, const struct gasmix *gasmix, int period_in_sec
int ci;
struct gas_pressures pressures;
- fill_pressures(&pressures, pressure - ((in_planner() && (prefs.deco_mode == VPMB)) ? WV_PRESSURE_SCHREINER : WV_PRESSURE),
+ fill_pressures(&pressures, pressure - ((in_planner() && (decoMode() == VPMB)) ? WV_PRESSURE_SCHREINER : WV_PRESSURE),
gasmix, (double) ccpo2 / 1000.0, dive->dc.divemode);
if (buehlmann_config.gf_low_at_maxdepth && pressure > gf_low_pressure_this_dive)
@@ -541,7 +542,7 @@ void add_segment(double pressure, const struct gasmix *gasmix, int period_in_sec
tissue_inertgas_saturation[ci] = tissue_n2_sat[ci] + tissue_he_sat[ci];
}
- if(prefs.deco_mode == VPMB)
+ if(decoMode() == VPMB)
calc_crushing_pressure(pressure);
return;
}
@@ -562,7 +563,7 @@ void clear_deco(double surface_pressure)
{
int ci;
for (ci = 0; ci < 16; ci++) {
- tissue_n2_sat[ci] = (surface_pressure - ((in_planner() && (prefs.deco_mode == VPMB)) ? WV_PRESSURE_SCHREINER : WV_PRESSURE)) * N2_IN_AIR / 1000;
+ 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;
max_n2_crushing_pressure[ci] = 0.0;
max_he_crushing_pressure[ci] = 0.0;