mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +00:00
Fix merging of weight systems
I just tried downloading some duplicate dives I had on my second dive computer, and it all "just worked" and subsurface merged them for me. Almost perfectly. I say "almost", because in merging them, it threw my old weightsystem data away, due to that not being merged. Also, it was a perfect merge only because the computers are so similar that they just line everything up - same water activation logic, same sample interval, same pretty much everything. So while I know the sample merging is not really the right thing to do (it was designed to get the "merge the exact same dive from the same computer" case right), it worked well enough for this particular case. I'll look at something better later. Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
parent
029db4aae2
commit
2d4fee7985
1 changed files with 18 additions and 3 deletions
21
dive.c
21
dive.c
|
@ -695,6 +695,23 @@ static void merge_cylinder_info(cylinder_t *res, cylinder_t *a, cylinder_t *b)
|
|||
MERGE_MIN(res, a, b, end.mbar);
|
||||
}
|
||||
|
||||
static void merge_weightsystem_info(weightsystem_t *res, weightsystem_t *a, weightsystem_t *b)
|
||||
{
|
||||
if (!a->weight.grams)
|
||||
a = b;
|
||||
*res = *a;
|
||||
}
|
||||
|
||||
static void merge_equipment(struct dive *res, struct dive *a, struct dive *b)
|
||||
{
|
||||
int i;
|
||||
|
||||
for (i = 0; i < MAX_CYLINDERS; i++)
|
||||
merge_cylinder_info(res->cylinder+i, a->cylinder + i, b->cylinder + i);
|
||||
for (i = 0; i < MAX_WEIGHTSYSTEMS; i++)
|
||||
merge_weightsystem_info(res->weightsystem+i, a->weightsystem + i, b->weightsystem + i);
|
||||
}
|
||||
|
||||
/*
|
||||
* This could do a lot more merging. Right now it really only
|
||||
* merges almost exact duplicates - something that happens easily
|
||||
|
@ -702,7 +719,6 @@ static void merge_cylinder_info(cylinder_t *res, cylinder_t *a, cylinder_t *b)
|
|||
*/
|
||||
struct dive *try_to_merge(struct dive *a, struct dive *b)
|
||||
{
|
||||
int i;
|
||||
struct dive *res;
|
||||
|
||||
if ((a->when >= b->when + 60) || (a->when <= b->when - 60))
|
||||
|
@ -734,8 +750,7 @@ struct dive *try_to_merge(struct dive *a, struct dive *b)
|
|||
MERGE_MAX(res, a, b, surfacetime.seconds);
|
||||
MERGE_MAX(res, a, b, airtemp.mkelvin);
|
||||
MERGE_MIN(res, a, b, watertemp.mkelvin);
|
||||
for (i = 0; i < MAX_CYLINDERS; i++)
|
||||
merge_cylinder_info(res->cylinder+i, a->cylinder + i, b->cylinder + i);
|
||||
merge_equipment(res, a, b);
|
||||
merge_events(res, a, b, 0);
|
||||
return merge_samples(res, a, b, 0);
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue