summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--core/deco.c2
-rw-r--r--core/deco.h2
-rw-r--r--core/dive.c48
-rw-r--r--core/dive.h32
-rw-r--r--core/divelist.c2
-rw-r--r--core/gaspressures.c2
-rw-r--r--core/planner.c4
-rw-r--r--core/plannernotes.c2
-rw-r--r--core/profile.c35
-rw-r--r--core/profile.h2
-rw-r--r--core/statistics.c4
-rw-r--r--profile-widget/diveprofileitem.cpp2
-rw-r--r--profile-widget/profilewidget2.cpp4
-rw-r--r--profile-widget/tankitem.cpp2
-rw-r--r--qt-models/diveplannermodel.cpp2
15 files changed, 76 insertions, 69 deletions
diff --git a/core/deco.c b/core/deco.c
index 2990edd7d..f072a2a17 100644
--- a/core/deco.c
+++ b/core/deco.c
@@ -581,7 +581,7 @@ void restore_deco_state(struct deco_state *data, struct deco_state *target, bool
}
-int deco_allowed_depth(double tissues_tolerance, double surface_pressure, struct dive *dive, bool smooth)
+int deco_allowed_depth(double tissues_tolerance, double surface_pressure, const struct dive *dive, bool smooth)
{
int depth;
double pressure_delta;
diff --git a/core/deco.h b/core/deco.h
index 075e7758c..717aa94cf 100644
--- a/core/deco.h
+++ b/core/deco.h
@@ -8,7 +8,7 @@ extern "C" {
extern double buehlmann_N2_t_halflife[];
-extern int deco_allowed_depth(double tissues_tolerance, double surface_pressure, struct dive *dive, bool smooth);
+extern int deco_allowed_depth(double tissues_tolerance, double surface_pressure, const struct dive *dive, bool smooth);
double get_gf(struct deco_state *ds, double ambpressure_bar, const struct dive *dive);
diff --git a/core/dive.c b/core/dive.c
index 8becbfdea..2a88f73f1 100644
--- a/core/dive.c
+++ b/core/dive.c
@@ -130,7 +130,7 @@ int legacy_format_o2pressures(struct dive *dive, struct divecomputer *dc)
return o2sensor < 0 ? 256 : o2sensor;
}
-int event_is_gaschange(struct event *ev)
+int event_is_gaschange(const struct event *ev)
{
return ev->type == SAMPLE_EVENT_GASCHANGE ||
ev->type == SAMPLE_EVENT_GASCHANGE2;
@@ -184,7 +184,7 @@ struct event *add_event(struct divecomputer *dc, unsigned int time, int type, in
return ev;
}
-static int same_event(struct event *a, struct event *b)
+static int same_event(const struct event *a, const struct event *b)
{
if (a->time.seconds != b->time.seconds)
return 0;
@@ -255,9 +255,9 @@ void add_extra_data(struct divecomputer *dc, const char *key, const char *value)
* saving the dive mode for each event. When the events occur AFTER 'time' seconds, the last stored divemode
* is returned. This function is self-tracking, relying on setting the event pointer 'evp' so that, in each iteration
* that calls this function, the search does not have to begin at the first event of the dive */
-enum divemode_t get_current_divemode(struct divecomputer *dc, int time, struct event **evp, enum divemode_t *divemode)
+enum divemode_t get_current_divemode(const struct divecomputer *dc, int time, const struct event **evp, enum divemode_t *divemode)
{
- struct event *ev = *evp;
+ const struct event *ev = *evp;
if (*divemode == UNDEF_COMP_TYPE) {
*divemode = dc->divemode;
ev = dc ? get_next_event(dc->events, "modechange") : NULL;
@@ -270,7 +270,7 @@ enum divemode_t get_current_divemode(struct divecomputer *dc, int time, struct e
return *divemode;
}
-struct gasmix get_gasmix_from_event(struct dive *dive, struct event *ev)
+struct gasmix get_gasmix_from_event(const struct dive *dive, const struct event *ev)
{
struct gasmix dummy = { 0 };
if (ev && event_is_gaschange(ev)) {
@@ -901,7 +901,7 @@ static unsigned int get_cylinder_used(struct dive *dive)
static unsigned int get_cylinder_known(struct dive *dive, struct divecomputer *dc)
{
unsigned int mask = 0;
- struct event *ev;
+ const struct event *ev;
/* We know about using the O2 cylinder in a CCR dive */
if (dc->divemode == CCR) {
@@ -973,7 +973,7 @@ void per_cylinder_mean_depth(struct dive *dive, struct divecomputer *dc, int *me
}
if (!dc->samples)
fake_dc(dc);
- struct event *ev = get_next_event(dc->events, "gaschange");
+ const struct event *ev = get_next_event(dc->events, "gaschange");
for (i = 0; i < dc->samples; i++) {
struct sample *sample = dc->sample + i;
uint32_t time = sample->time.seconds;
@@ -1039,10 +1039,10 @@ static int same_rounded_pressure(pressure_t a, pressure_t b)
* tell us what the first gas is with a gas change event in the first sample.
* Sneakily we'll use a return value of 0 (or FALSE) when there is no explicit
* first cylinder - in which case cylinder 0 is indeed the first cylinder */
-int explicit_first_cylinder(struct dive *dive, struct divecomputer *dc)
+int explicit_first_cylinder(const struct dive *dive, const struct divecomputer *dc)
{
if (dc) {
- struct event *ev = get_next_event(dc->events, "gaschange");
+ const struct event *ev = get_next_event(dc->events, "gaschange");
if (ev && ((dc->sample && ev->time.seconds == dc->sample[0].time.seconds) || ev->time.seconds <= 1))
return get_cylinder_index(dive, ev);
else if (dc->divemode == CCR)
@@ -1054,7 +1054,7 @@ int explicit_first_cylinder(struct dive *dive, struct divecomputer *dc)
/* this gets called when the dive mode has changed (so OC vs. CC)
* there are two places we might have setpoints... events or in the samples
*/
-void update_setpoint_events(struct dive *dive, struct divecomputer *dc)
+void update_setpoint_events(const struct dive *dive, struct divecomputer *dc)
{
struct event *ev;
int new_setpoint = 0;
@@ -1071,9 +1071,9 @@ void update_setpoint_events(struct dive *dive, struct divecomputer *dc)
// by mistake when it's actually CCR is _bad_
// So we make sure, this comes from a Predator or Petrel and we only remove
// pO2 values we would have computed anyway.
- struct event *ev = get_next_event(dc->events, "gaschange");
+ const struct event *ev = get_next_event(dc->events, "gaschange");
struct gasmix gasmix = get_gasmix_from_event(dive, ev);
- struct event *next = get_next_event(ev, "gaschange");
+ const struct event *next = get_next_event(ev, "gaschange");
for (int i = 0; i < dc->samples; i++) {
struct gas_pressures pressures;
@@ -1091,7 +1091,7 @@ void update_setpoint_events(struct dive *dive, struct divecomputer *dc)
// an "SP change" event at t=0 is currently our marker for OC vs CCR
// this will need to change to a saner setup, but for now we can just
// check if such an event is there and adjust it, or add that event
- ev = get_next_event(dc->events, "SP change");
+ ev = get_next_event_mutable(dc->events, "SP change");
if (ev && ev->time.seconds == 0) {
ev->value = new_setpoint;
} else {
@@ -1241,7 +1241,7 @@ bool isobaric_counterdiffusion(struct gasmix oldgasmix, struct gasmix newgasmix,
}
/* some events should never be thrown away */
-static bool is_potentially_redundant(struct event *event)
+static bool is_potentially_redundant(const struct event *event)
{
if (!strcmp(event->name, "gaschange"))
return false;
@@ -1608,7 +1608,7 @@ static void fixup_dive_pressures(struct dive *dive, struct divecomputer *dc)
simplify_dc_pressures(dc);
}
-int find_best_gasmix_match(struct gasmix mix, cylinder_t array[], unsigned int used)
+int find_best_gasmix_match(struct gasmix mix, const cylinder_t array[], unsigned int used)
{
int i;
int best = -1, score = INT_MAX;
@@ -1968,7 +1968,7 @@ static char *merge_text(const char *a, const char *b, const char *sep)
if (a->field != b->field) \
return a->field < b->field ? -1 : 1
-static int sort_event(struct event *a, struct event *b)
+static int sort_event(const struct event *a, const struct event *b)
{
SORT(a, b, time.seconds);
SORT(a, b, type);
@@ -1977,7 +1977,7 @@ static int sort_event(struct event *a, struct event *b)
return strcmp(a->name, b->name);
}
-static int same_gas(struct event *a, struct event *b)
+static int same_gas(const struct event *a, const struct event *b)
{
if (a->type == b->type && a->flags == b->flags && a->value == b->value && !strcmp(a->name, b->name) &&
same_gasmix(a->gas.mix, b->gas.mix)) {
@@ -2068,7 +2068,7 @@ static void merge_weightsystem_info(weightsystem_t *res, weightsystem_t *a, weig
* A negative number returned indicates that a match could not be found.
* Call parameters: dive = the dive being processed
* cylinder_use_type = an enum, one of {oxygen, diluent, bailout} */
-extern int get_cylinder_idx_by_use(struct dive *dive, enum cylinderuse cylinder_use_type)
+extern int get_cylinder_idx_by_use(const struct dive *dive, enum cylinderuse cylinder_use_type)
{
int cylinder_index;
for (cylinder_index = 0; cylinder_index < MAX_CYLINDERS; cylinder_index++) {
@@ -2137,7 +2137,7 @@ extern void fill_pressures(struct gas_pressures *pressures, const double amb_pre
/* Force an initial gaschange event to the (old) gas #0 */
static void add_initial_gaschange(struct dive *dive, struct divecomputer *dc)
{
- struct event *ev = get_next_event(dc->events, "gaschange");
+ const struct event *ev = get_next_event(dc->events, "gaschange");
if (ev && ev->time.seconds < 30)
return;
@@ -2874,7 +2874,7 @@ static int same_sample(struct sample *a, struct sample *b)
static int same_dc(struct divecomputer *a, struct divecomputer *b)
{
int i;
- struct event *eva, *evb;
+ const struct event *eva, *evb;
i = match_one_dc(a, b);
if (i)
@@ -4287,9 +4287,9 @@ int dive_has_gps_location(const struct dive *dive)
return dive_site_has_gps_location(get_dive_site_by_uuid(dive->dive_site_uuid));
}
-struct gasmix get_gasmix(struct dive *dive, struct divecomputer *dc, int time, struct event **evp, struct gasmix gasmix)
+struct gasmix get_gasmix(const struct dive *dive, const struct divecomputer *dc, int time, const struct event **evp, struct gasmix gasmix)
{
- struct event *ev = *evp;
+ const struct event *ev = *evp;
struct gasmix res;
if (!ev) {
@@ -4310,9 +4310,9 @@ struct gasmix get_gasmix(struct dive *dive, struct divecomputer *dc, int time, s
}
/* get the gas at a certain time during the dive */
-struct gasmix get_gasmix_at_time(struct dive *d, struct divecomputer *dc, duration_t time)
+struct gasmix get_gasmix_at_time(const struct dive *d, const struct divecomputer *dc, duration_t time)
{
- struct event *ev = NULL;
+ const struct event *ev = NULL;
struct gasmix gasmix = { 0 };
return get_gasmix(d, dc, time.seconds, &ev, gasmix);
}
diff --git a/core/dive.h b/core/dive.h
index b1b5d3208..45b35190e 100644
--- a/core/dive.h
+++ b/core/dive.h
@@ -100,7 +100,7 @@ struct event {
char name[];
};
-extern int event_is_gaschange(struct event *ev);
+extern int event_is_gaschange(const struct event *ev);
extern int get_pressure_units(int mb, const char **units);
extern double get_depth_units(int mm, int *frac, const char **units);
@@ -137,7 +137,7 @@ extern void fill_pressures(struct gas_pressures *pressures, const double amb_pre
extern void sanitize_gasmix(struct gasmix *mix);
extern int gasmix_distance(struct gasmix a, struct gasmix b);
-extern int find_best_gasmix_match(struct gasmix mix, cylinder_t array[], unsigned int used);
+extern int find_best_gasmix_match(struct gasmix mix, const cylinder_t array[], unsigned int used);
extern bool gasmix_is_air(struct gasmix gasmix);
@@ -334,7 +334,7 @@ struct dive {
extern void invalidate_dive_cache(struct dive *dive);
extern bool dive_cache_is_valid(const struct dive *dive);
-extern int get_cylinder_idx_by_use(struct dive *dive, enum cylinderuse cylinder_use_type);
+extern int get_cylinder_idx_by_use(const struct dive *dive, enum cylinderuse cylinder_use_type);
extern void cylinder_renumber(struct dive *dive, int mapping[]);
extern int same_gasmix_cylinder(cylinder_t *cyl, int cylid, struct dive *dive, bool check_unused);
@@ -352,9 +352,9 @@ struct dive_components {
unsigned int weights : 1;
};
-extern enum divemode_t get_current_divemode(struct divecomputer *dc, int time, struct event **evp, enum divemode_t *divemode);
-extern struct event *get_next_divemodechange(struct event **evd, bool update_pointer);
-extern enum divemode_t get_divemode_at_time(struct divecomputer *dc, int dtime, struct event **ev_dmc);
+extern enum divemode_t get_current_divemode(const struct divecomputer *dc, int time, const struct event **evp, enum divemode_t *divemode);
+extern struct event *get_next_divemodechange(const struct event **evd, bool update_pointer);
+extern enum divemode_t get_divemode_at_time(const struct divecomputer *dc, int dtime, const struct event **ev_dmc);
/* picture list and methods related to dive picture handling */
struct picture {
@@ -382,8 +382,8 @@ extern bool picture_check_valid(const char *filename, int shift_time);
extern void dive_set_geodata_from_picture(struct dive *d, struct picture *pic);
extern void picture_free(struct picture *picture);
-extern bool has_gaschange_event(struct dive *dive, struct divecomputer *dc, int idx);
-extern int explicit_first_cylinder(struct dive *dive, struct divecomputer *dc);
+extern bool has_gaschange_event(const struct dive *dive, const struct divecomputer *dc, int idx);
+extern int explicit_first_cylinder(const struct dive *dive, const struct divecomputer *dc);
extern int get_depth_at_time(const struct divecomputer *dc, unsigned int time);
extern fraction_t best_o2(depth_t depth, const struct dive *dive);
@@ -581,11 +581,11 @@ extern void fill_default_cylinder(cylinder_t *cyl);
extern void add_gas_switch_event(struct dive *dive, struct divecomputer *dc, int time, int idx);
extern struct event *add_event(struct divecomputer *dc, unsigned int time, int type, int flags, int value, const char *name);
extern void remove_event(struct event *event);
-extern void update_event_name(struct dive *d, struct event* event, const char *name);
+extern void update_event_name(struct dive *d, struct event *event, const char *name);
extern void add_extra_data(struct divecomputer *dc, const char *key, const char *value);
extern void per_cylinder_mean_depth(struct dive *dive, struct divecomputer *dc, int *mean, int *duration);
-extern int get_cylinder_index(struct dive *dive, struct event *ev);
-extern struct gasmix get_gasmix_from_event(struct dive *, struct event *ev);
+extern int get_cylinder_index(const struct dive *dive, const struct event *ev);
+extern struct gasmix get_gasmix_from_event(const struct dive *, const struct event *ev);
extern int nr_cylinders(struct dive *dive);
extern int nr_weightsystems(struct dive *dive);
@@ -716,16 +716,18 @@ extern void vpmb_start_gradient(struct deco_state *ds);
extern void clear_vpmb_state(struct deco_state *ds);
extern void printdecotable(struct decostop *table);
-extern struct event *get_next_event(struct event *event, const char *name);
+/* Since C doesn't have parameter-based overloading, two versions of get_next_event. */
+extern const struct event *get_next_event(const struct event *event, const char *name);
+extern struct event *get_next_event_mutable(struct event *event, const char *name);
/* Get gasmixes at increasing timestamps.
* In "evp", pass a pointer to a "struct event *" which is NULL-initialized on first invocation.
* On subsequent calls, pass the same "evp" and the "gasmix" from previous calls.
*/
-extern struct gasmix get_gasmix(struct dive *dive, struct divecomputer *dc, int time, struct event **evp, struct gasmix gasmix);
+extern struct gasmix get_gasmix(const struct dive *dive, const struct divecomputer *dc, int time, const struct event **evp, struct gasmix gasmix);
/* Get gasmix at a given time */
-extern struct gasmix get_gasmix_at_time(struct dive *dive, struct divecomputer *dc, duration_t time);
+extern struct gasmix get_gasmix_at_time(const struct dive *dive, const struct divecomputer *dc, duration_t time);
/* these structs holds the information that
* describes the cylinders / weight systems.
@@ -762,7 +764,7 @@ extern void set_informational_units(const char *units);
extern void set_git_prefs(const char *prefs);
extern char *get_dive_date_c_string(timestamp_t when);
-extern void update_setpoint_events(struct dive *dive, struct divecomputer *dc);
+extern void update_setpoint_events(const struct dive *dive, struct divecomputer *dc);
#ifdef __cplusplus
}
diff --git a/core/divelist.c b/core/divelist.c
index 18e9b1ae3..44ad7c79f 100644
--- a/core/divelist.c
+++ b/core/divelist.c
@@ -405,7 +405,7 @@ static void add_dive_to_deco(struct deco_state *ds, struct dive *dive)
struct divecomputer *dc = &dive->dc;
struct gasmix gasmix = { 0 };
int i;
- struct event *ev = NULL, *evd = NULL;
+ const struct event *ev = NULL, *evd = NULL;
enum divemode_t current_divemode = UNDEF_COMP_TYPE;
if (!dc)
diff --git a/core/gaspressures.c b/core/gaspressures.c
index 626d617bf..1b191369b 100644
--- a/core/gaspressures.c
+++ b/core/gaspressures.c
@@ -350,7 +350,7 @@ void populate_pressure_information(struct dive *dive, struct divecomputer *dc, s
cylinder_t *cylinder = dive->cylinder + sensor;
pr_track_t *track = NULL;
pr_track_t *current = NULL;
- struct event *ev, *b_ev;
+ const struct event *ev, *b_ev;
int missing_pr = 0, dense = 1;
enum divemode_t dmode = dc->divemode;
const double gasfactor[5] = {1.0, 0.0, prefs.pscr_ratio/1000.0, 1.0, 1.0 };
diff --git a/core/planner.c b/core/planner.c
index 673c2b6b7..1077fb313 100644
--- a/core/planner.c
+++ b/core/planner.c
@@ -136,7 +136,7 @@ int tissue_at_end(struct deco_state *ds, struct dive *dive, struct deco_state **
return 0;
psample = sample = dc->sample;
- struct event *evdm = NULL;
+ const struct event *evdm = NULL;
enum divemode_t divemode = UNDEF_COMP_TYPE;
for (i = 0; i < dc->samples; i++, sample++) {
@@ -716,7 +716,7 @@ bool plan(struct deco_state *ds, struct diveplan *diveplan, struct dive *dive, i
current_cylinder = get_cylinderid_at_time(dive, &dive->dc, sample->time);
// FIXME: This needs a function to find the divemode at the end of the dive like in
- struct event *ev = NULL;
+ const struct event *ev = NULL;
divemode = UNDEF_COMP_TYPE;
divemode = get_current_divemode(&dive->dc, bottom_time, &ev, &divemode);
gas = dive->cylinder[current_cylinder].gasmix;
diff --git a/core/plannernotes.c b/core/plannernotes.c
index 27742f2f9..133f9a591 100644
--- a/core/plannernotes.c
+++ b/core/plannernotes.c
@@ -551,7 +551,7 @@ void add_plan_to_notes(struct diveplan *diveplan, struct dive *dive, bool show_d
bool o2warning_exist = false;
enum divemode_t current_divemode;
double amb;
- struct event *evd = NULL;
+ const struct event *evd = NULL;
current_divemode = UNDEF_COMP_TYPE;
if (dive->dc.divemode != CCR) {
diff --git a/core/profile.c b/core/profile.c
index cfda49163..47fc97723 100644
--- a/core/profile.c
+++ b/core/profile.c
@@ -316,7 +316,7 @@ struct plot_info *analyze_plot_info(struct plot_info *pi)
* Some dive computers give cylinder indexes, some
* give just the gas mix.
*/
-int get_cylinder_index(struct dive *dive, struct event *ev)
+int get_cylinder_index(const struct dive *dive, const struct event *ev)
{
int best;
struct gasmix mix;
@@ -337,7 +337,7 @@ int get_cylinder_index(struct dive *dive, struct event *ev)
return best < 0 ? 0 : best;
}
-struct event *get_next_event(struct event *event, const char *name)
+struct event *get_next_event_mutable(struct event *event, const char *name)
{
if (!name || !*name)
return NULL;
@@ -349,6 +349,11 @@ struct event *get_next_event(struct event *event, const char *name)
return event;
}
+const struct event *get_next_event(const struct event *event, const char *name)
+{
+ return get_next_event_mutable((struct event *)event, name);
+}
+
static int count_events(struct divecomputer *dc)
{
int result = 0;
@@ -372,13 +377,13 @@ static int set_setpoint(struct plot_info *pi, int i, int setpoint, int end)
return i;
}
-static void check_setpoint_events(struct dive *dive, struct divecomputer *dc, struct plot_info *pi)
+static void check_setpoint_events(const struct dive *dive, struct divecomputer *dc, struct plot_info *pi)
{
UNUSED(dive);
int i = 0;
pressure_t setpoint;
setpoint.mbar = 0;
- struct event *ev = get_next_event(dc->events, "SP change");
+ const struct event *ev = get_next_event(dc->events, "SP change");
if (!ev)
return;
@@ -776,7 +781,7 @@ static unsigned int matching_gases(struct dive *dive, struct gasmix gasmix)
static void calculate_sac(struct dive *dive, struct divecomputer *dc, struct plot_info *pi)
{
struct gasmix gasmix = { 0 };
- struct event *ev = NULL;
+ const struct event *ev = NULL;
unsigned int gases = 0;
for (int i = 0; i < pi->nr; i++) {
@@ -791,7 +796,7 @@ static void calculate_sac(struct dive *dive, struct divecomputer *dc, struct plo
}
}
-static void populate_secondary_sensor_data(struct divecomputer *dc, struct plot_info *pi)
+static void populate_secondary_sensor_data(const struct divecomputer *dc, struct plot_info *pi)
{
UNUSED(dc);
UNUSED(pi);
@@ -818,14 +823,14 @@ static void add_plot_pressure(struct plot_info *pi, int time, int cyl, pressure_
SENSOR_PRESSURE(entry, cyl) = p.mbar;
}
-static void setup_gas_sensor_pressure(struct dive *dive, struct divecomputer *dc, struct plot_info *pi)
+static void setup_gas_sensor_pressure(const struct dive *dive, const struct divecomputer *dc, struct plot_info *pi)
{
int prev, i;
- struct event *ev;
+ const struct event *ev;
int seen[MAX_CYLINDERS] = { 0, };
unsigned int first[MAX_CYLINDERS] = { 0, };
unsigned int last[MAX_CYLINDERS] = { 0, };
- struct divecomputer *secondary;
+ const struct divecomputer *secondary;
prev = explicit_first_cylinder(dive, dc);
seen[prev] = 1;
@@ -854,7 +859,7 @@ static void setup_gas_sensor_pressure(struct dive *dive, struct divecomputer *dc
// Fill in "seen[]" array - mark cylinders we're not interested
// in as negative.
for (i = 0; i < MAX_CYLINDERS; i++) {
- cylinder_t *cyl = dive->cylinder + i;
+ const cylinder_t *cyl = dive->cylinder + i;
int start = cyl->start.mbar;
int end = cyl->end.mbar;
@@ -885,7 +890,7 @@ static void setup_gas_sensor_pressure(struct dive *dive, struct divecomputer *dc
for (i = 0; i < MAX_CYLINDERS; i++) {
if (seen[i] >= 0) {
- cylinder_t *cyl = dive->cylinder + i;
+ const cylinder_t *cyl = dive->cylinder + i;
add_plot_pressure(pi, first[i], i, cyl->start);
add_plot_pressure(pi, last[i], i, cyl->end);
@@ -907,7 +912,7 @@ static void setup_gas_sensor_pressure(struct dive *dive, struct divecomputer *dc
#ifndef SUBSURFACE_MOBILE
/* calculate DECO STOP / TTS / NDL */
-static void calculate_ndl_tts(struct deco_state *ds, struct dive *dive, struct plot_data *entry, struct gasmix gasmix, double surface_pressure,enum divemode_t divemode)
+static void calculate_ndl_tts(struct deco_state *ds, const struct dive *dive, struct plot_data *entry, struct gasmix gasmix, double surface_pressure,enum divemode_t divemode)
{
/* FIXME: This should be configurable */
/* ascent speed up to first deco stop */
@@ -990,7 +995,7 @@ static void calculate_ndl_tts(struct deco_state *ds, struct dive *dive, struct p
/* Let's try to do some deco calculations.
*/
-void calculate_deco_information(struct deco_state *ds, struct deco_state *planner_ds, struct dive *dive, struct divecomputer *dc, struct plot_info *pi, bool print_mode)
+void calculate_deco_information(struct deco_state *ds, const struct deco_state *planner_ds, const struct dive *dive, const struct divecomputer *dc, struct plot_info *pi, bool print_mode)
{
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;
@@ -1017,7 +1022,7 @@ void calculate_deco_information(struct deco_state *ds, struct deco_state *planne
if (decoMode() == VPMB)
ds->first_ceiling_pressure.mbar = depth_to_mbar(first_ceiling, dive);
struct gasmix gasmix = { 0 };
- struct event *ev = NULL, *evd = NULL;
+ const struct event *ev = NULL, *evd = NULL;
enum divemode_t current_divemode = UNDEF_COMP_TYPE;
for (i = 1; i < pi->nr; i++) {
@@ -1206,7 +1211,7 @@ static void calculate_gas_information_new(struct dive *dive, struct divecomputer
int i;
double amb_pressure;
struct gasmix gasmix = { 0 };
- struct event *evg = NULL, *evd = NULL;
+ const struct event *evg = NULL, *evd = NULL;
enum divemode_t current_divemode = UNDEF_COMP_TYPE;
for (i = 1; i < pi->nr; i++) {
diff --git a/core/profile.h b/core/profile.h
index 58c44d955..9e714a806 100644
--- a/core/profile.h
+++ b/core/profile.h
@@ -77,7 +77,7 @@ void compare_samples(struct plot_data *e1, struct plot_data *e2, char *buf, int
struct plot_data *populate_plot_entries(struct dive *dive, struct divecomputer *dc, struct plot_info *pi);
struct plot_info *analyze_plot_info(struct plot_info *pi);
void create_plot_info_new(struct dive *dive, struct divecomputer *dc, struct plot_info *pi, bool fast, struct deco_state *planner_ds);
-void calculate_deco_information(struct deco_state *ds, struct deco_state *planner_de, struct dive *dive, struct divecomputer *dc, struct plot_info *pi, bool print_mode);
+void calculate_deco_information(struct deco_state *ds, const struct deco_state *planner_de, const struct dive *dive, const struct divecomputer *dc, struct plot_info *pi, bool print_mode);
struct plot_data *get_plot_details_new(struct plot_info *pi, int time, struct membuffer *);
/*
diff --git a/core/statistics.c b/core/statistics.c
index bb32095cc..b518a9c7f 100644
--- a/core/statistics.c
+++ b/core/statistics.c
@@ -236,10 +236,10 @@ void process_selected_dives(void)
#define SOME_GAS 5000 // 5bar drop in cylinder pressure makes cylinder used
-bool has_gaschange_event(struct dive *dive, struct divecomputer *dc, int idx)
+bool has_gaschange_event(const struct dive *dive, const struct divecomputer *dc, int idx)
{
bool first_gas_explicit = false;
- struct event *event = get_next_event(dc->events, "gaschange");
+ const struct event *event = get_next_event(dc->events, "gaschange");
while (event) {
if (dc->sample && (event->time.seconds == 0 ||
(dc->samples && dc->sample[0].time.seconds == event->time.seconds)))
diff --git a/profile-widget/diveprofileitem.cpp b/profile-widget/diveprofileitem.cpp
index 5a359b3e8..932586f12 100644
--- a/profile-widget/diveprofileitem.cpp
+++ b/profile-widget/diveprofileitem.cpp
@@ -411,7 +411,7 @@ void DivePercentageItem::paint(QPainter *painter, const QStyleOptionGraphicsItem
if (i < poly.count()) {
double value = dataModel->index(i, vDataColumn).data().toDouble();
struct gasmix gasmix = { 0 };
- struct event *ev = NULL;
+ const struct event *ev = NULL;
int sec = dataModel->index(i, DivePlotDataModel::TIME).data().toInt();
gasmix = get_gasmix(&displayed_dive, displayed_dc, sec, &ev, gasmix);
int inert = 1000 - get_o2(gasmix);
diff --git a/profile-widget/profilewidget2.cpp b/profile-widget/profilewidget2.cpp
index 4ea1f36d2..a40908e5c 100644
--- a/profile-widget/profilewidget2.cpp
+++ b/profile-widget/profilewidget2.cpp
@@ -1452,7 +1452,7 @@ void ProfileWidget2::contextMenuEvent(QContextMenuEvent *event)
action->setData(event->globalPos());
QAction *splitAction = m.addAction(tr("Split dive into two"), this, SLOT(splitDive()));
splitAction->setData(event->globalPos());
- struct event *ev = NULL;
+ const struct event *ev = NULL;
enum divemode_t divemode = UNDEF_COMP_TYPE;
QPointF scenePos = mapToScene(mapFromGlobal(event->globalPos()));
QString gas = action->text();
@@ -1695,7 +1695,7 @@ void ProfileWidget2::changeGas()
// if there is a gas change at this time stamp, remove it before adding the new one
struct event *gasChangeEvent = current_dc->events;
- while ((gasChangeEvent = get_next_event(gasChangeEvent, "gaschange")) != NULL) {
+ while ((gasChangeEvent = get_next_event_mutable(gasChangeEvent, "gaschange")) != NULL) {
if (gasChangeEvent->time.seconds == seconds) {
remove_event(gasChangeEvent);
gasChangeEvent = current_dc->events;
diff --git a/profile-widget/tankitem.cpp b/profile-widget/tankitem.cpp
index 5a8b8ca48..2bbcdc1a7 100644
--- a/profile-widget/tankitem.cpp
+++ b/profile-widget/tankitem.cpp
@@ -108,7 +108,7 @@ void TankItem::modelDataChanged(const QModelIndex&, const QModelIndex&)
int startTime = 0;
// work through all the gas changes and add the rectangle for each gas while it was used
- struct event *ev = get_next_event(dc->events, "gaschange");
+ const struct event *ev = get_next_event(dc->events, "gaschange");
while (ev && (int)ev->time.seconds < last_entry->sec) {
width = hAxis->posAtValue(ev->time.seconds) - hAxis->posAtValue(startTime);
left = hAxis->posAtValue(startTime);
diff --git a/qt-models/diveplannermodel.cpp b/qt-models/diveplannermodel.cpp
index 6f783b104..32231ecca 100644
--- a/qt-models/diveplannermodel.cpp
+++ b/qt-models/diveplannermodel.cpp
@@ -81,7 +81,7 @@ void DivePlannerPointsModel::loadFromDive(dive *d)
o2pressure_t last_sp;
bool oldRec = recalc;
struct divecomputer *dc = &(d->dc);
- struct event *evd = NULL;
+ const struct event *evd = NULL;
enum divemode_t current_divemode = UNDEF_COMP_TYPE;
recalc = false;
CylindersModel::instance()->updateDive();