summaryrefslogtreecommitdiffstats
path: root/core
diff options
context:
space:
mode:
authorGravatar Berthold Stoeger <bstoeger@mail.tuwien.ac.at>2021-01-09 18:25:04 +0100
committerGravatar Dirk Hohndel <dirk@hohndel.org>2021-01-10 15:57:39 -0800
commit88c6ce988dfc1b5ad40eb9c425d705c8ac136570 (patch)
tree49a7642f6fa40b2a8a3e65e9d4ebc48dfc51e29a /core
parent54e8fe5d9e588c3345ded27982edaf72654fc8d1 (diff)
downloadsubsurface-88c6ce988dfc1b5ad40eb9c425d705c8ac136570.tar.gz
profile: pass dive to RulerItem
Instead of accessing the global displayed_dive variable in RulerItem, pass the dive. This is a step in making the profile reentrant. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Diffstat (limited to 'core')
-rw-r--r--core/profile.c8
-rw-r--r--core/profile.h2
2 files changed, 5 insertions, 5 deletions
diff --git a/core/profile.c b/core/profile.c
index 2cd34f2a0..2670cf03f 100644
--- a/core/profile.c
+++ b/core/profile.c
@@ -1585,7 +1585,7 @@ int get_plot_details_new(const struct dive *d, const struct plot_info *pi, int t
}
/* Compare two plot_data entries and writes the results into a string */
-void compare_samples(struct plot_info *pi, int idx1, int idx2, char *buf, int bufsize, bool sum)
+void compare_samples(const struct dive *d, const struct plot_info *pi, int idx1, int idx2, char *buf, int bufsize, bool sum)
{
struct plot_data *start, *stop, *data;
const char *depth_unit, *pressure_unit, *vertical_speed_unit;
@@ -1691,11 +1691,11 @@ void compare_samples(struct plot_info *pi, int idx1, int idx2, char *buf, int bu
memcpy(buf2, buf, bufsize);
/* Only print if gas has been used */
- if (bar_used) {
+ if (bar_used && d->cylinders.nr > 0) {
pressurevalue = get_pressure_units(bar_used, &pressure_unit);
memcpy(buf2, buf, bufsize);
snprintf_loc(buf, bufsize, translate("gettextFromC", "%s ΔP:%d%s"), buf2, pressurevalue, pressure_unit);
- cylinder_t *cyl = get_cylinder(&displayed_dive, 0);
+ cylinder_t *cyl = get_cylinder(d, 0);
/* if we didn't cross a tank change and know the cylidner size as well, show SAC rate */
if (!crossed_tankchange && cyl->type.size.mliter) {
double volume_value;
@@ -1713,7 +1713,7 @@ void compare_samples(struct plot_info *pi, int idx1, int idx2, char *buf, int bu
int volume_used = gas_volume(cyl, first_pressure) - gas_volume(cyl, stop_pressure);
/* Mean pressure in ATM */
- double atm = depth_to_atm(avg_depth, &displayed_dive);
+ double atm = depth_to_atm(avg_depth, d);
/* milliliters per minute */
int sac = lrint(volume_used / atm * 60 / delta_time);
diff --git a/core/profile.h b/core/profile.h
index 725bbae18..67e7791fc 100644
--- a/core/profile.h
+++ b/core/profile.h
@@ -80,7 +80,7 @@ struct plot_data {
bool icd_warning;
};
-extern void compare_samples(struct plot_info *p1, int idx1, int idx2, char *buf, int bufsize, bool sum);
+extern void compare_samples(const struct dive *d, const struct plot_info *pi, int idx1, int idx2, char *buf, int bufsize, bool sum);
extern void init_plot_info(struct plot_info *pi);
/* when planner_dc is non-null, this is called in planner mode. */
extern void create_plot_info_new(struct dive *dive, struct divecomputer *dc, struct plot_info *pi, bool fast, const struct deco_state *planner_ds);