[PATCH] Always show deco gas as dive gas

Joakim Bygdell j.bygdell at gmail.com
Tue Jan 6 08:38:43 PST 2015


> On 06 Jan 2015, at 17:15, Anton Lundin <glance at acc.umu.se> wrote:
> 
> This unifies how we prints Nitrox deco gas dives with Trimix deco gas
> dives.
> 
> Signed-off-by: Anton Lundin <glance at acc.umu.se>
> ---
> 
> This is the opposite from what Jocke's patch does. After looking at my dive
> list i think i actually like this one better.
> 
> What do other folks think?
> 
> divelist.c | 27 +++++++++++++++------------
> 1 file changed, 15 insertions(+), 12 deletions(-)
> 
> diff --git a/divelist.c b/divelist.c
> index ce67414..886e2a2 100644
> --- a/divelist.c
> +++ b/divelist.c
> @@ -106,7 +106,7 @@ int trip_has_selected_dives(dive_trip_t *trip)
>  *  - Nitrox trumps air (even if hypoxic)
>  * These are the same rules as the inter-dive sorting rules.
>  */
> -void get_dive_gas(struct dive *dive, int *o2_p, int *he_p, int *o2low_p)
> +void get_dive_gas(struct dive *dive, int *o2_p, int *he_p, int *o2max_p)
> {
> 	int i;
> 	int maxo2 = -1, maxhe = -1, mino2 = 1000;
> @@ -121,8 +121,8 @@ void get_dive_gas(struct dive *dive, int *o2_p, int *he_p, int *o2low_p)
> 			continue;
> 		if (cylinder_none(cyl))
> 			continue;
> -		if (o2 < mino2)
> -			mino2 = o2;
> +		if (o2 > maxo2)
> +			maxo2 = o2;
> 		if (he > maxhe)
> 			goto newmax;
> 		if (he < maxhe)
> @@ -131,14 +131,14 @@ void get_dive_gas(struct dive *dive, int *o2_p, int *he_p, int *o2low_p)
> 			continue;
> 	newmax:
> 		maxhe = he;
> -		maxo2 = o2;
> +		mino2 = o2;
> 	}
> 	/* All air? Show/sort as "air"/zero */
> 	if (!maxhe && maxo2 == O2_IN_AIR && mino2 == maxo2)
> 		maxo2 = mino2 = 0;
> -	*o2_p = maxo2;
> +	*o2_p = mino2;
> 	*he_p = maxhe;
> -	*o2low_p = mino2;
> +	*o2max_p = maxo2;
> }
> 
> int total_weight(struct dive *dive)
> @@ -444,22 +444,25 @@ void update_cylinder_related_info(struct dive *dive)
> /* callers needs to free the string */
> char *get_dive_gas_string(struct dive *dive)
> {
> -	int o2, he, o2low;
> +	int o2, he, o2max;
> 	char *buffer = malloc(MAX_GAS_STRING);
> 
> 	if (buffer) {
> -		get_dive_gas(dive, &o2, &he, &o2low);
> +		get_dive_gas(dive, &o2, &he, &o2max);
> 		o2 = (o2 + 5) / 10;
> 		he = (he + 5) / 10;
> -		o2low = (o2low + 5) / 10;
> +		o2max = (o2max + 5) / 10;
> 
> 		if (he)
> -			snprintf(buffer, MAX_GAS_STRING, "%d/%d", o2, he);
> +			if (o2 == o2max)
> +				snprintf(buffer, MAX_GAS_STRING, "%d/%d", he, o2);

Shouldn’t this line read	snprintf(buffer, MAX_GAS_STRING, "%d/%d", o2, he);
or you will get really low fO2 in your air-topped gas mix.

> +			else
> +				snprintf(buffer, MAX_GAS_STRING, "%d/%d" UTF8_ELLIPSIS "%d%%", o2, he, o2max);
> 		else if (o2)
> -			if (o2 == o2low)
> +			if (o2 == o2max)
> 				snprintf(buffer, MAX_GAS_STRING, "%d%%", o2);
> 			else
> -				snprintf(buffer, MAX_GAS_STRING, "%d" UTF8_ELLIPSIS "%d%%", o2low, o2);
> +				snprintf(buffer, MAX_GAS_STRING, "%d" UTF8_ELLIPSIS "%d%%", o2, o2max);
> 		else
> 			strcpy(buffer, translate("gettextFromC", "air"));
> 	}
> -- 
> 2.1.0
> 

/Jocke



More information about the subsurface mailing list