aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--divelist.c2
-rw-r--r--planner.c11
-rw-r--r--qt-ui/diveplanner.cpp3
3 files changed, 8 insertions, 8 deletions
diff --git a/divelist.c b/divelist.c
index 2abeac9ca..1e279efca 100644
--- a/divelist.c
+++ b/divelist.c
@@ -153,7 +153,7 @@ int total_weight(struct dive *dive)
static int active_o2(struct dive *dive, struct divecomputer *dc, duration_t time)
{
- struct gasmix gas = dive->cylinder[0].gasmix;
+ struct gasmix gas;
get_gas_at_time(dive, dc, time, &gas);
return get_o2(&gas);
}
diff --git a/planner.c b/planner.c
index dc80729ec..3cad8d132 100644
--- a/planner.c
+++ b/planner.c
@@ -94,11 +94,13 @@ void set_display_transitions(bool display)
plan_display_transitions = display;
}
+/* get the gas at a certain time during the dive */
void get_gas_at_time(struct dive *dive, struct divecomputer *dc, duration_t time, struct gasmix *gas)
{
- // we don't modify the values passed in if nothing is found
- // so don't call with uninitialized gasmix !
+ // we always start with the first gas, so that's our gas
+ // unless an event tells us otherwise
struct event *event = dc->events;
+ *gas = dive->cylinder[0].gasmix;
while (event && event->time.seconds <= time.seconds) {
if (!strcmp(event->name, "gaschange")) {
int cylinder_idx = get_cylinder_index(dive, event);
@@ -153,8 +155,7 @@ double tissue_at_end(struct dive *dive, char **cached_datap)
if (!dc->samples)
return tissue_tolerance;
psample = sample = dc->sample;
- /* we always start with gas 0 (unless an event tells us otherwise) */
- gas = dive->cylinder[0].gasmix;
+
for (i = 0; i < dc->samples; i++, sample++) {
t1 = sample->time;
get_gas_at_time(dive, dc, t0, &gas);
@@ -551,7 +552,7 @@ static void add_plan_to_notes(struct diveplan *diveplan, struct dive *dive, bool
translate("gettextFromC", "gas"));
}
do {
- struct gasmix gasmix, newgasmix;
+ struct gasmix gasmix, newgasmix = {};
const char *depth_unit;
double depthvalue;
int decimals;
diff --git a/qt-ui/diveplanner.cpp b/qt-ui/diveplanner.cpp
index 8bd32f457..285347237 100644
--- a/qt-ui/diveplanner.cpp
+++ b/qt-ui/diveplanner.cpp
@@ -106,8 +106,7 @@ void DivePlannerPointsModel::loadFromDive(dive *d)
{
CylindersModel::instance()->updateDive();
duration_t lasttime = {};
- // we start with the first gas and see if it was changed
- struct gasmix gas = d->cylinder[0].gasmix;
+ struct gasmix gas;
for (int i = 0; i < d->dc.samples - 1; i++) {
const sample &s = d->dc.sample[i];
if (s.time.seconds == 0)