summaryrefslogtreecommitdiffstats
path: root/profile.c
diff options
context:
space:
mode:
authorGravatar Dirk Hohndel <dirk@hohndel.org>2014-06-01 12:07:29 -0700
committerGravatar Dirk Hohndel <dirk@hohndel.org>2014-06-01 12:07:29 -0700
commit1a040134538b7733f3088ea34f101cfedecc2c64 (patch)
tree53eb0fc9dd65f3e75fb886075cc5b952b3800157 /profile.c
parentfb4d9b34f87f71b072bccb36633d7247b9d9dd9d (diff)
downloadsubsurface-1a040134538b7733f3088ea34f101cfedecc2c64.tar.gz
Encapsulate the horrid gas encoding in gas change events
We should never pass permille values around as integers. And we shouldn't have to decode the stupid value in more than one place. This doesn't tackle all the places where we access O2 and He "too early" and should instead keep passing around a gaxmix. But it's a first step. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Diffstat (limited to 'profile.c')
-rw-r--r--profile.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/profile.c b/profile.c
index 35af28f25..d3934e308 100644
--- a/profile.c
+++ b/profile.c
@@ -578,13 +578,15 @@ int get_cylinder_index(struct dive *dive, struct event *ev)
int i;
int best = 0, score = INT_MAX;
int target_o2, target_he;
+ struct gasmix *g;
/*
* Crazy gas change events give us odd encoded o2/he in percent.
* Decode into our internal permille format.
*/
- target_o2 = (ev->value & 0xFFFF) * 10;
- target_he = (ev->value >> 16) * 10;
+ g = get_gasmix_from_event(ev);
+ target_o2 = get_o2(g);
+ target_he = get_he(g);
/*
* Try to find a cylinder that best matches the target gas