Older compilers didn't really like this one, so hold this one for
now...

On 14 May, 2014 - Anton Lundin wrote:

> We use mod calculations on multiple places, so make a separate helper
> from it with proper types.
> 
> Signed-off-by: Anton Lundin <[email protected]>
> ---
>  dive.h                | 4 ++++
>  profile.c             | 3 ++-
>  qt-ui/diveplanner.cpp | 5 +----
>  3 files changed, 7 insertions(+), 5 deletions(-)
> 
> diff --git a/dive.h b/dive.h
> index b27eff2..c96287b 100644
> --- a/dive.h
> +++ b/dive.h
> @@ -104,6 +104,10 @@ static inline int interpolate(int a, int b, int part, 
> int whole)
>       return rint(x / whole);
>  }
>  
> +static inline depth_t gas_mod(struct gasmix *mix, pressure_t po2_limit) {
> +     return (depth_t) { .mm = po2_limit.mbar * 1000 / get_o2(mix) * 10 - 
> 10000 };
> +}
> +
>  struct sample {
>       duration_t time;
>       depth_t depth;
> diff --git a/profile.c b/profile.c
> index fea0330..f88e2be 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;
> +             entry->mod = (double) 
> gas_mod(&dive->cylinder[cylinderindex].gasmix,
> +                             (pressure_t) { .mbar = (int) (prefs.modppO2 * 
> 1000) }).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) *
> diff --git a/qt-ui/diveplanner.cpp b/qt-ui/diveplanner.cpp
> index b45b4e0..b562c7c 100644
> --- a/qt-ui/diveplanner.cpp
> +++ b/qt-ui/diveplanner.cpp
> @@ -1257,10 +1257,7 @@ bool DivePlannerPointsModel::addGas(int o2, int he)
>                       cyl->gasmix.he.permille = he;
>                       /* The depth to change to that gas is given by the 
> depth where its pO2 is 1.6 bar.
>                        * The user should be able to change this depth 
> manually. */
> -                     if (!o2)
> -                             cyl->depth.mm = 1600 * 1000 / O2_IN_AIR * 10 - 
> 10000;
> -                     else
> -                             cyl->depth.mm = 1600 * 1000 / o2 * 10 - 10000;
> +                     cyl->depth = gas_mod(&cyl->gasmix, (pressure_t) { .mbar 
> = 1600 });
>                       CylindersModel::instance()->setDive(stagingDive);
>                       return true;
>               }
> -- 
> 1.9.1

-- 
Anton Lundin    +46702-161604
_______________________________________________
subsurface mailing list
[email protected]
http://lists.hohndel.org/cgi-bin/mailman/listinfo/subsurface

Reply via email to