mirror of
https://github.com/subsurface/subsurface.git
synced 2025-01-31 21:03:23 +00:00
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>
This commit is contained in:
parent
ae6f5f0a5a
commit
37830bdb53
1 changed files with 15 additions and 12 deletions
27
divelist.c
27
divelist.c
|
@ -106,7 +106,7 @@ int trip_has_selected_dives(dive_trip_t *trip)
|
||||||
* - Nitrox trumps air (even if hypoxic)
|
* - Nitrox trumps air (even if hypoxic)
|
||||||
* These are the same rules as the inter-dive sorting rules.
|
* 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 i;
|
||||||
int maxo2 = -1, maxhe = -1, mino2 = 1000;
|
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;
|
continue;
|
||||||
if (cylinder_none(cyl))
|
if (cylinder_none(cyl))
|
||||||
continue;
|
continue;
|
||||||
if (o2 < mino2)
|
if (o2 > maxo2)
|
||||||
mino2 = o2;
|
maxo2 = o2;
|
||||||
if (he > maxhe)
|
if (he > maxhe)
|
||||||
goto newmax;
|
goto newmax;
|
||||||
if (he < maxhe)
|
if (he < maxhe)
|
||||||
|
@ -131,14 +131,14 @@ void get_dive_gas(struct dive *dive, int *o2_p, int *he_p, int *o2low_p)
|
||||||
continue;
|
continue;
|
||||||
newmax:
|
newmax:
|
||||||
maxhe = he;
|
maxhe = he;
|
||||||
maxo2 = o2;
|
mino2 = o2;
|
||||||
}
|
}
|
||||||
/* All air? Show/sort as "air"/zero */
|
/* All air? Show/sort as "air"/zero */
|
||||||
if (!maxhe && maxo2 == O2_IN_AIR && mino2 == maxo2)
|
if (!maxhe && maxo2 == O2_IN_AIR && mino2 == maxo2)
|
||||||
maxo2 = mino2 = 0;
|
maxo2 = mino2 = 0;
|
||||||
*o2_p = maxo2;
|
*o2_p = mino2;
|
||||||
*he_p = maxhe;
|
*he_p = maxhe;
|
||||||
*o2low_p = mino2;
|
*o2max_p = maxo2;
|
||||||
}
|
}
|
||||||
|
|
||||||
int total_weight(struct dive *dive)
|
int total_weight(struct dive *dive)
|
||||||
|
@ -444,22 +444,25 @@ void update_cylinder_related_info(struct dive *dive)
|
||||||
/* callers needs to free the string */
|
/* callers needs to free the string */
|
||||||
char *get_dive_gas_string(struct dive *dive)
|
char *get_dive_gas_string(struct dive *dive)
|
||||||
{
|
{
|
||||||
int o2, he, o2low;
|
int o2, he, o2max;
|
||||||
char *buffer = malloc(MAX_GAS_STRING);
|
char *buffer = malloc(MAX_GAS_STRING);
|
||||||
|
|
||||||
if (buffer) {
|
if (buffer) {
|
||||||
get_dive_gas(dive, &o2, &he, &o2low);
|
get_dive_gas(dive, &o2, &he, &o2max);
|
||||||
o2 = (o2 + 5) / 10;
|
o2 = (o2 + 5) / 10;
|
||||||
he = (he + 5) / 10;
|
he = (he + 5) / 10;
|
||||||
o2low = (o2low + 5) / 10;
|
o2max = (o2max + 5) / 10;
|
||||||
|
|
||||||
if (he)
|
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)
|
else if (o2)
|
||||||
if (o2 == o2low)
|
if (o2 == o2max)
|
||||||
snprintf(buffer, MAX_GAS_STRING, "%d%%", o2);
|
snprintf(buffer, MAX_GAS_STRING, "%d%%", o2);
|
||||||
else
|
else
|
||||||
snprintf(buffer, MAX_GAS_STRING, "%d" UTF8_ELLIPSIS "%d%%", o2low, o2);
|
snprintf(buffer, MAX_GAS_STRING, "%d" UTF8_ELLIPSIS "%d%%", o2, o2max);
|
||||||
else
|
else
|
||||||
strcpy(buffer, translate("gettextFromC", "air"));
|
strcpy(buffer, translate("gettextFromC", "air"));
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue