diff options
author | Anton Lundin <glance@acc.umu.se> | 2015-01-06 21:49:42 +0100 |
---|---|---|
committer | Dirk Hohndel <dirk@hohndel.org> | 2015-01-06 15:04:10 -0800 |
commit | 37830bdb53192ff1d38342a15ca47d49c138a425 (patch) | |
tree | 9773aeb418101c61c35aa533794197c3b333b711 /divelist.c | |
parent | ae6f5f0a5ae9c903cb766a175d0fbaa8f440e62b (diff) | |
download | subsurface-37830bdb53192ff1d38342a15ca47d49c138a425.tar.gz |
Always show deco gas as dive gas
This unifies how we prints Nitrox deco gas dives with Trimix deco gas
dives.
Reviewed-By: Joakim Bygdell <j.bygdell@gmail.com>
Signed-off-by: Anton Lundin <glance@acc.umu.se>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Diffstat (limited to 'divelist.c')
-rw-r--r-- | divelist.c | 27 |
1 files changed, 15 insertions, 12 deletions
diff --git a/divelist.c b/divelist.c index ce67414b5..ba11f02c1 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", o2, he); + 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")); } |