mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +00:00
No gas change event on merging dives with same gas
When merging dives, this will skip the gas change event if both dives use same gas. Fixes #1099 Signed-off-by: Miika Turkia <miika.turkia@gmail.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
parent
f9e6a3ecc6
commit
b5de08b709
1 changed files with 22 additions and 0 deletions
22
core/dive.c
22
core/dive.c
|
@ -1765,6 +1765,15 @@ static int sort_event(struct event *a, struct event *b)
|
||||||
return strcmp(a->name, b->name);
|
return strcmp(a->name, b->name);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int same_gas(struct event *a, struct event *b)
|
||||||
|
{
|
||||||
|
if (a->type == b->type && a->flags == b->flags && a->value == b->value && !strcmp(a->name, b->name) &&
|
||||||
|
a->gas.mix.o2.permille == b->gas.mix.o2.permille && a->gas.mix.he.permille == b->gas.mix.he.permille) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
static void merge_events(struct divecomputer *res, struct divecomputer *src1, struct divecomputer *src2, int offset)
|
static void merge_events(struct divecomputer *res, struct divecomputer *src1, struct divecomputer *src2, int offset)
|
||||||
{
|
{
|
||||||
struct event *a, *b;
|
struct event *a, *b;
|
||||||
|
@ -1799,6 +1808,19 @@ static void merge_events(struct divecomputer *res, struct divecomputer *src1, st
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
s = sort_event(a, b);
|
s = sort_event(a, b);
|
||||||
|
|
||||||
|
/* No gas change event when continuing with same gas */
|
||||||
|
if (same_gas(a, b)) {
|
||||||
|
if (s > 0) {
|
||||||
|
p = &b->next;
|
||||||
|
b = b->next;
|
||||||
|
} else {
|
||||||
|
p = &a->next;
|
||||||
|
a = a->next;
|
||||||
|
}
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
/* Pick b */
|
/* Pick b */
|
||||||
if (s > 0) {
|
if (s > 0) {
|
||||||
*p = b;
|
*p = b;
|
||||||
|
|
Loading…
Add table
Reference in a new issue