From 950638ec1c560083cbf7c49fc0a5e6139560cc85 Mon Sep 17 00:00:00 2001 From: Anton Lundin Date: Thu, 17 Jul 2014 17:19:19 +0200 Subject: Replace cylinder_is_used with is_cylinder_used is_cylinder_used uses get_cylinder_index as underlaying function that does the right thing with with respect on how to find the closest matching cylinder, and handles both types of gaschange events correctly. Signed-off-by: Anton Lundin Signed-off-by: Dirk Hohndel --- equipment.c | 25 ------------------------- 1 file changed, 25 deletions(-) (limited to 'equipment.c') diff --git a/equipment.c b/equipment.c index 14d02df77..8ca9f096e 100644 --- a/equipment.c +++ b/equipment.c @@ -73,31 +73,6 @@ bool cylinder_none(void *_data) return cylinder_nodata(cyl) && cylinder_nosamples(cyl); } -/* look at all dive computers and figure out if this cylinder is used anywhere - * d has to be a valid dive (test before calling) - * cyl does not have to be a cylinder that is part of this dive structure */ -bool cylinder_is_used(struct dive *d, cylinder_t *cyl) -{ - struct divecomputer *dc = &d->dc; - bool same_as_first = gasmix_distance(&cyl->gasmix, &d->cylinder[0].gasmix) < 200; - while (dc) { - struct event *ev = get_next_event(dc->events, "gaschange"); - if (same_as_first && (!ev || ev->time.seconds > 30)) { - // unless there is a gas change in the first 30 seconds we can - // always mark the first cylinder as used - return true; - } - while (ev) { - if (gasmix_distance(&cyl->gasmix, get_gasmix_from_event(ev)) < 200) - return true; - - ev = get_next_event(ev->next, "gaschange"); - } - dc = dc->next; - } - return false; -} - void get_gas_string(const struct gasmix *gasmix, char *text, int len) { if (gasmix_is_air(gasmix)) -- cgit v1.2.3-70-g09d2