From 123f3ef7ec8f977c9949c3ac24008163c722e208 Mon Sep 17 00:00:00 2001 From: "Robert C. Helling" Date: Tue, 1 Jan 2019 18:49:56 +0100 Subject: Filter for logged/planned dives Add filter for dives having a planned dive computer or a logged dive computer. Signed-off-by: Robert C. Helling --- core/dive.c | 12 ++++++++++++ core/dive.h | 2 ++ 2 files changed, 14 insertions(+) (limited to 'core') diff --git a/core/dive.c b/core/dive.c index 0ec9e381c..36d05dad5 100644 --- a/core/dive.c +++ b/core/dive.c @@ -3361,6 +3361,18 @@ bool is_dc_planner(const struct divecomputer *dc) { return same_string(dc->model, "planned dive"); } +// Does this dive have a dive computer for which is_dc_planner has value planned +bool has_planned(const struct dive *dive, bool planned) { + const struct divecomputer *dc = &dive->dc; + + while (dc) { + if (is_dc_planner(&dive->dc) == planned) + return true; + dc = dc->next; + } + return false; +} + /* * Merging two dives can be subtle, because there's two different ways * of merging: diff --git a/core/dive.h b/core/dive.h index f447c88b5..a93020507 100644 --- a/core/dive.h +++ b/core/dive.h @@ -653,6 +653,8 @@ extern void vpmb_start_gradient(struct deco_state *ds); extern void vpmb_next_gradient(struct deco_state *ds, double deco_time, double surface_pressure); extern double tissue_tolerance_calc(struct deco_state *ds, const struct dive *dive, double pressure); extern bool is_dc_planner(const struct divecomputer *dc); +extern bool has_planned(const struct dive *dive, bool planned); + /* this should be converted to use our types */ struct divedatapoint { -- cgit v1.2.3-70-g09d2