aboutsummaryrefslogtreecommitdiffstats
path: root/profile.c
diff options
context:
space:
mode:
authorGravatar Anton Lundin <glance@acc.umu.se>2014-05-25 12:30:51 +0200
committerGravatar Dirk Hohndel <dirk@hohndel.org>2014-05-25 06:20:52 -0700
commitff966f2c1ab7a28bec2aa9f5ca8cca94bb7654e2 (patch)
treef28226bdbae1048d55b1555d02de2ea98f028cd5 /profile.c
parenta85023a661928142da2b9d78775099b4a080569d (diff)
downloadsubsurface-ff966f2c1ab7a28bec2aa9f5ca8cca94bb7654e2.tar.gz
Move mod calculations to a separate helper
We use mod calculations on multiple places, so make a separate helper from it with proper types. The "clumsiness" of defining a local variable to pass into the function and out from it comes from the discrepancies in how c and c++ handles initializations of variables in a struct. Thanks goes to Tiago and Linus for pointing me in the right direction. 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.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/profile.c b/profile.c
index fea03308d..26b267dd0 100644
--- a/profile.c
+++ b/profile.c
@@ -1155,7 +1155,8 @@ static void calculate_gas_information_new(struct dive *dive, struct plot_info *p
* so there is no difference in calculating between OC and CC
* END takes O2 + N2 (air) into account ("Narcotic" for trimix dives)
* EAD just uses N2 ("Air" for nitrox dives) */
- entry->mod = (prefs.modppO2 / fo2 * 1000 - 1) * 10000;
+ pressure_t modppO2 = { .mbar = (int) (prefs.modppO2 * 1000) };
+ entry->mod = (double) gas_mod(&dive->cylinder[cylinderindex].gasmix, modppO2).mm;
entry->end = (entry->depth + 10000) * (1000 - fhe) / 1000.0 - 10000;
entry->ead = (entry->depth + 10000) * (1000 - fo2 - fhe) / (double)N2_IN_AIR - 10000;
entry->eadd = (entry->depth + 10000) *