summaryrefslogtreecommitdiffstats
path: root/core/planner.c
diff options
context:
space:
mode:
authorGravatar Linus Torvalds <torvalds@linux-foundation.org>2016-04-02 15:06:54 -0500
committerGravatar Dirk Hohndel <dirk@hohndel.org>2016-04-04 22:37:18 -0700
commite0824ef9f3e2a0cc0fae435b8e3560b309d9708e (patch)
tree4597890128bc8ebee2dfb4335dc5c9b855e4a68e /core/planner.c
parent7a444c0210783b926c9f60dd7b436eb086e8f396 (diff)
downloadsubsurface-e0824ef9f3e2a0cc0fae435b8e3560b309d9708e.tar.gz
Make gas change events always have a cylinder index
In commit df4e26c8757a ("Start sanitizing gaschange event information") back about a year and a half ago, I started sanitizing the gas switch event data, allowing gas switches to be associated with a particular cylinder index rather than just the gas mix that is switched to. But that initial step only _allowed_ a gas switch event to be associated with a particular cylinder, the primary model was still to just specify the mix. This finally takes the next step, and *always* associates a gas switch event with a particular cylinder. Instead of then looking up the cylinder by trying to match gas mixes at runtime, subsurface now looks it up when loading the dive initially as part of the dive fixup code. The switch event still has an a separate gas mix associated with it, but this patch also starts preparing for entirely relying on the gas mix in the cylinder itself, by starting to pass in not just the event but also the dive pointer to the routines that look up gas mix details. Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Diffstat (limited to 'core/planner.c')
-rw-r--r--core/planner.c7
1 files changed, 1 insertions, 6 deletions
diff --git a/core/planner.c b/core/planner.c
index 705aad1cb..a58c698ab 100644
--- a/core/planner.c
+++ b/core/planner.c
@@ -94,12 +94,7 @@ void get_gas_at_time(struct dive *dive, struct divecomputer *dc, duration_t time
int get_gasidx(struct dive *dive, struct gasmix *mix)
{
- int gasidx = -1;
-
- while (++gasidx < MAX_CYLINDERS)
- if (gasmix_distance(&dive->cylinder[gasidx].gasmix, mix) < 100)
- return gasidx;
- return -1;
+ return find_best_gasmix_match(mix, dive->cylinder, 0);
}
void interpolate_transition(struct dive *dive, duration_t t0, duration_t t1, depth_t d0, depth_t d1, const struct gasmix *gasmix, o2pressure_t po2)