diff --git a/core/deco.cpp b/core/deco.cpp index 7460f12da..b21c6b908 100644 --- a/core/deco.cpp +++ b/core/deco.cpp @@ -221,7 +221,7 @@ double tissue_tolerance_calc(struct deco_state *ds, const struct dive *dive, dou double ret_tolerance_limit_ambient_pressure = 0.0; double gf_high = buehlmann_config.gf_high; double gf_low = buehlmann_config.gf_low; - double surface = get_surface_pressure_in_mbar(dive, true) / 1000.0; + double surface = dive->get_surface_pressure().mbar / 1000.0; double lowest_ceiling = 0.0; double tissue_lowest_ceiling[16]; @@ -582,7 +582,7 @@ void set_vpmb_conservatism(short conservatism) double get_gf(struct deco_state *ds, double ambpressure_bar, const struct dive *dive) { - double surface_pressure_bar = get_surface_pressure_in_mbar(dive, true) / 1000.0; + double surface_pressure_bar = dive->get_surface_pressure().mbar / 1000.0; double gf_low = buehlmann_config.gf_low; double gf_high = buehlmann_config.gf_high; double gf; diff --git a/core/dive.cpp b/core/dive.cpp index 8a2feb1ce..28ecf1dfd 100644 --- a/core/dive.cpp +++ b/core/dive.cpp @@ -2382,12 +2382,10 @@ bool dive::cache_is_valid() const return git_id != null_id; } -int get_surface_pressure_in_mbar(const struct dive *dive, bool non_null) +pressure_t dive::get_surface_pressure() const { - int mbar = dive->surface_pressure.mbar; - if (!mbar && non_null) - mbar = SURFACE_PRESSURE; - return mbar; + return surface_pressure.mbar > 0 ? surface_pressure + : pressure_t { SURFACE_PRESSURE }; } /* This returns the conversion factor that you need to multiply diff --git a/core/dive.h b/core/dive.h index 16d25d91d..ac9f560a6 100644 --- a/core/dive.h +++ b/core/dive.h @@ -89,6 +89,7 @@ struct dive { duration_t totaltime() const; /* maximum over divecomputers (with samples) */ temperature_t dc_airtemp() const; /* average over divecomputers */ temperature_t dc_watertemp() const; /* average over divecomputers */ + pressure_t get_surface_pressure() const; struct get_maximal_gas_result { int o2_p; int he_p; int o2low_p; }; get_maximal_gas_result get_maximal_gas() const; @@ -158,8 +159,6 @@ struct dive_components { extern fraction_t best_o2(depth_t depth, const struct dive *dive, bool in_planner); extern fraction_t best_he(depth_t depth, const struct dive *dive, bool o2narcotic, fraction_t fo2); -extern int get_surface_pressure_in_mbar(const struct dive *dive, bool non_null); - extern struct dive_site *get_dive_site_for_dive(const struct dive *dive); extern std::string get_dive_country(const struct dive *dive); extern std::string get_dive_location(const struct dive *dive); diff --git a/core/divelist.cpp b/core/divelist.cpp index 4e1d6aa6f..601ffa9a0 100644 --- a/core/divelist.cpp +++ b/core/divelist.cpp @@ -537,7 +537,7 @@ int dive_table::init_decompression(struct deco_state *ds, const struct dive *div printf("Yes\n"); #endif - surface_pressure = get_surface_pressure_in_mbar(&pdive, true) / 1000.0; + surface_pressure = pdive.get_surface_pressure().mbar / 1000.0; /* Is it the first dive we add? */ if (!deco_init) { #if DECO_CALC_DEBUG & 2 @@ -575,7 +575,7 @@ int dive_table::init_decompression(struct deco_state *ds, const struct dive *div #endif } - surface_pressure = get_surface_pressure_in_mbar(dive, true) / 1000.0; + surface_pressure = dive->get_surface_pressure().mbar / 1000.0; /* We don't have had a previous dive at all? */ if (!deco_init) { #if DECO_CALC_DEBUG & 2 diff --git a/core/profile.cpp b/core/profile.cpp index 8eaec8fb8..eae5f718f 100644 --- a/core/profile.cpp +++ b/core/profile.cpp @@ -841,7 +841,7 @@ static void calculate_deco_information(struct deco_state *ds, const struct deco_ const struct divecomputer *dc, struct plot_info &pi) { int i, count_iteration = 0; - double surface_pressure = (dc->surface_pressure.mbar ? dc->surface_pressure.mbar : get_surface_pressure_in_mbar(dive, true)) / 1000.0; + double surface_pressure = (dc->surface_pressure.mbar ? dc->surface_pressure.mbar : dive->get_surface_pressure().mbar) / 1000.0; bool first_iteration = true; int prev_deco_time = 10000000, time_deep_ceiling = 0; bool in_planner = planner_ds != NULL;