mirror of
https://github.com/subsurface/subsurface.git
synced 2024-11-28 13:10:19 +00:00
When merging planned dives keep all cylinders
When merging a real dive with a planned dive (for comparison), we should not try to be clever in merging similar cylinders, rather keep the union of both cylinder sets as the two versions of the dive might differ in exctly which gas and how much of it was used. Increase MAX_CYLINDERS to 20 to make room for this. Signed-off-by: Robert C. Helling <helling@atdotde.de>
This commit is contained in:
parent
99595542ec
commit
a031dbbbd8
2 changed files with 40 additions and 15 deletions
25
core/dive.c
25
core/dive.c
|
@ -2028,6 +2028,8 @@ static void merge_cylinders(struct dive *res, struct dive *a, struct dive *b)
|
|||
memcpy(res->cylinder, a->cylinder, sizeof(res->cylinder));
|
||||
memset(a->cylinder, 0, sizeof(a->cylinder));
|
||||
|
||||
if (strcmp(b->dc.model, "planned dive")) {
|
||||
// We merge two actual dive
|
||||
for (i = 0; i < MAX_CYLINDERS; i++) {
|
||||
int j;
|
||||
cylinder_t *cyl = b->cylinder + i;
|
||||
|
@ -2045,6 +2047,24 @@ static void merge_cylinders(struct dive *res, struct dive *a, struct dive *b)
|
|||
}
|
||||
if (renumber)
|
||||
cylinder_renumber(b, mapping);
|
||||
} else {
|
||||
int j=0;
|
||||
for (i = 0; i < MAX_CYLINDERS && j < MAX_CYLINDERS; i++) {
|
||||
if (is_cylinder_used(res, i))
|
||||
continue;
|
||||
|
||||
while (!is_cylinder_used(b, j) && j < MAX_CYLINDERS - 1) {
|
||||
mapping[j] = 0;
|
||||
++j;
|
||||
}
|
||||
memcpy(&res->cylinder[i], &b->cylinder[j], sizeof (b->cylinder[j]));
|
||||
mapping[j] = i;
|
||||
++j;
|
||||
}
|
||||
while (j < MAX_CYLINDERS)
|
||||
mapping[j++] = 0;
|
||||
cylinder_renumber(b, mapping);
|
||||
}
|
||||
}
|
||||
|
||||
static void merge_equipment(struct dive *res, struct dive *a, struct dive *b)
|
||||
|
@ -3000,6 +3020,11 @@ struct dive *merge_dives(struct dive *a, struct dive *b, int offset, bool prefer
|
|||
dl = b;
|
||||
}
|
||||
|
||||
if (!strcmp(a->dc.model, "planneed dive")) {
|
||||
struct dive *tmp = a;
|
||||
a = b;
|
||||
b = tmp;
|
||||
}
|
||||
res->when = dl ? dl->when : a->when;
|
||||
res->selected = a->selected || b->selected;
|
||||
merge_trip(res, a, b);
|
||||
|
|
|
@ -290,7 +290,7 @@ struct divecomputer {
|
|||
struct divecomputer *next;
|
||||
};
|
||||
|
||||
#define MAX_CYLINDERS (8)
|
||||
#define MAX_CYLINDERS (20)
|
||||
#define MAX_WEIGHTSYSTEMS (6)
|
||||
#define W_IDX_PRIMARY 0
|
||||
#define W_IDX_SECONDARY 1
|
||||
|
|
Loading…
Reference in a new issue