mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +00:00
Take only used gases into account when showing gas in divelist
Here is a patch that restricts the gases listed in the divelist to those that are actually used. I seem to have the indentation now under control but I am not sure about the logic: 1) First gas (with index 0) is always used. 2) If there is a gas switch event, the new gas is also used (determined by walking the list of dive computers and then the list of events). Signed-off-by: Robert C. Helling <helling@atdotde.de> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
parent
8a5792d473
commit
ae4bd802af
1 changed files with 28 additions and 0 deletions
28
divelist.c
28
divelist.c
|
@ -459,11 +459,39 @@ static void get_dive_gas(struct dive *dive, int *o2_p, int *he_p, int *o2low_p)
|
||||||
int i;
|
int i;
|
||||||
int maxo2 = -1, maxhe = -1, mino2 = 1000;
|
int maxo2 = -1, maxhe = -1, mino2 = 1000;
|
||||||
|
|
||||||
|
|
||||||
for (i = 0; i < MAX_CYLINDERS; i++) {
|
for (i = 0; i < MAX_CYLINDERS; i++) {
|
||||||
cylinder_t *cyl = dive->cylinder + i;
|
cylinder_t *cyl = dive->cylinder + i;
|
||||||
struct gasmix *mix = &cyl->gasmix;
|
struct gasmix *mix = &cyl->gasmix;
|
||||||
int o2 = mix->o2.permille;
|
int o2 = mix->o2.permille;
|
||||||
int he = mix->he.permille;
|
int he = mix->he.permille;
|
||||||
|
struct divecomputer *dc = &dive->dc;
|
||||||
|
int used = !i; /* The first gas is always used */
|
||||||
|
|
||||||
|
while (dc){
|
||||||
|
struct event *event = dc->events;
|
||||||
|
while(event){
|
||||||
|
if (event->value) {
|
||||||
|
if (event->name && !strcmp(event->name, "gaschange")) {
|
||||||
|
unsigned int event_he = event->value >> 16;
|
||||||
|
unsigned int event_o2 = event->value & 0xffff;
|
||||||
|
|
||||||
|
if (is_air(o2, he)){
|
||||||
|
if (is_air(event_o2 * 10, event_he * 10))
|
||||||
|
used = 1;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
if (he == event_he*10 && o2 == event_o2*10)
|
||||||
|
used = 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
event = event->next;
|
||||||
|
}
|
||||||
|
dc = dc->next;
|
||||||
|
}
|
||||||
|
if (!used)
|
||||||
|
continue;
|
||||||
|
|
||||||
if (cylinder_none(cyl))
|
if (cylinder_none(cyl))
|
||||||
continue;
|
continue;
|
||||||
|
|
Loading…
Add table
Reference in a new issue