summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--core/dive.c8
-rw-r--r--core/dive.h5
-rw-r--r--core/divelist.c3
-rw-r--r--core/planner.c18
-rw-r--r--core/planner.h1
-rw-r--r--profile-widget/profilewidget2.cpp3
6 files changed, 15 insertions, 23 deletions
diff --git a/core/dive.c b/core/dive.c
index 6d9945932..0cf0df780 100644
--- a/core/dive.c
+++ b/core/dive.c
@@ -4308,3 +4308,11 @@ struct gasmix get_gasmix(struct dive *dive, struct divecomputer *dc, int time, s
*evp = ev;
return res;
}
+
+/* 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 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 7e62262d9..a1cc3ab6d 100644
--- a/core/dive.h
+++ b/core/dive.h
@@ -718,12 +718,15 @@ extern void printdecotable(struct decostop *table);
extern struct event *get_next_event(struct event *event, const char *name);
-/* Get gasmix at increasing timestamps.
+/* 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);
+/* Get gasmix at a given time */
+extern struct gasmix get_gasmix_at_time(struct dive *dive, struct divecomputer *dc, duration_t time);
+
/* these structs holds the information that
* describes the cylinders / weight systems.
* they are global variables initialized in equipment.c
diff --git a/core/divelist.c b/core/divelist.c
index 9c2484417..12382d896 100644
--- a/core/divelist.c
+++ b/core/divelist.c
@@ -134,8 +134,7 @@ int total_weight(struct dive *dive)
static int active_o2(struct dive *dive, struct divecomputer *dc, duration_t time)
{
- struct gasmix gas;
- get_gas_at_time(dive, dc, time, &gas);
+ struct gasmix gas = get_gasmix_at_time(dive, dc, time);
return get_o2(&gas);
}
diff --git a/core/planner.c b/core/planner.c
index eefa94143..ec2436a70 100644
--- a/core/planner.c
+++ b/core/planner.c
@@ -81,22 +81,6 @@ bool diveplan_empty(struct diveplan *diveplan)
return true;
}
-/* 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 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);
- *gas = dive->cylinder[cylinder_idx].gasmix;
- }
- event = event->next;
- }
-}
-
/* get the cylinder index at a certain time during the dive */
int get_cylinderid_at_time(struct dive *dive, struct divecomputer *dc, duration_t time)
{
@@ -164,7 +148,7 @@ int tissue_at_end(struct deco_state *ds, struct dive *dive, struct deco_state **
setpoint = sample[0].setpoint;
t1 = sample->time;
- get_gas_at_time(dive, dc, t0, &gas);
+ gas = get_gasmix_at_time(dive, dc, t0);
if (i > 0)
lastdepth = psample->depth;
diff --git a/core/planner.h b/core/planner.h
index 741f83c02..a96633b74 100644
--- a/core/planner.h
+++ b/core/planner.h
@@ -17,7 +17,6 @@ extern void set_verbatim(bool verbatim);
extern void set_display_runtime(bool display);
extern void set_display_duration(bool display);
extern void set_display_transitions(bool display);
-extern void get_gas_at_time(struct dive *dive, struct divecomputer *dc, duration_t time, struct gasmix *gas);
extern int get_cylinderid_at_time(struct dive *dive, struct divecomputer *dc, duration_t time);
extern int get_gasidx(struct dive *dive, struct gasmix *mix);
extern bool diveplan_empty(struct diveplan *diveplan);
diff --git a/profile-widget/profilewidget2.cpp b/profile-widget/profilewidget2.cpp
index d9875681a..9371047bd 100644
--- a/profile-widget/profilewidget2.cpp
+++ b/profile-widget/profilewidget2.cpp
@@ -758,8 +758,7 @@ void ProfileWidget2::plotDive(struct dive *d, bool force, bool doClearPictures)
qDeleteAll(eventItems);
eventItems.clear();
struct event *event = currentdc->events;
- struct event *ev;
- struct gasmix lastgasmix = get_gasmix(&displayed_dive, current_dc, 1, &ev, NULL);
+ struct gasmix lastgasmix = get_gasmix_at_time(&displayed_dive, current_dc, duration_t{1});
while (event) {
#ifndef SUBSURFACE_MOBILE