summaryrefslogtreecommitdiffstats
path: root/profile.c
diff options
context:
space:
mode:
authorGravatar Anton Lundin <glance@acc.umu.se>2013-09-18 09:06:38 +0200
committerGravatar Dirk Hohndel <dirk@hohndel.org>2013-09-18 11:59:20 -0500
commit93d6eb13977aaf1e17fbb1861a2df001b67b8303 (patch)
tree4abeeb5fee6a367ca618d22377146c924b1fceea /profile.c
parentb75aee33fec6c624c0746c10006fa7098d24c582 (diff)
downloadsubsurface-93d6eb13977aaf1e17fbb1861a2df001b67b8303.tar.gz
Only calculate with he when he is present in event
Old gasswitch events only contains O2, so don't look at he part when the event doesn't contain a He part. Signed-off-by: Anton Lundin <glance@acc.umu.se> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Diffstat (limited to 'profile.c')
-rw-r--r--profile.c9
1 files changed, 8 insertions, 1 deletions
diff --git a/profile.c b/profile.c
index eb6be2cac..5c947fbfa 100644
--- a/profile.c
+++ b/profile.c
@@ -646,7 +646,14 @@ static int get_cylinder_index(struct dive *dive, struct event *ev)
delta_o2 = get_o2(&cyl->gasmix) - target_o2;
delta_he = get_he(&cyl->gasmix) - target_he;
- distance = delta_o2 * delta_o2 + delta_he * delta_he;
+ distance = delta_o2 * delta_o2;
+
+ /* Check the event type to figure out if we should care about the he part.
+ * 11 is SAMPLE_EVENT_GASCHANGE, aka without he
+ * 25 is SAMPLE_EVENT_GASCHANGE2, aka with he
+ */
+ if (ev->type == 25)
+ distance += delta_he * delta_he;
if (distance >= score)
continue;
score = distance;