summaryrefslogtreecommitdiffstats
path: root/core/dive.c
diff options
context:
space:
mode:
authorGravatar Linus Torvalds <torvalds@linux-foundation.org>2018-07-01 14:30:34 -0700
committerGravatar Dirk Hohndel <dirk@hohndel.org>2018-07-02 08:38:31 -0700
commit90569e0ee66a61e33938fc952e0755ccd790b9de (patch)
tree09fd94c2a6c1a7dc7f87b207b78746d9a43b22e9 /core/dive.c
parent3209b490ddda7b029392a030e34097b921bfd025 (diff)
downloadsubsurface-90569e0ee66a61e33938fc952e0755ccd790b9de.tar.gz
Use (and update) dive computer times when merging and splitting dives
When we split a dive in two, we keep the dive computer ID for the dive, but we should update the actual _time_ of the split dive to match the split. And when we look for "are these the exact same dives", we should check not only that the dive computer dive ID matches, but also that the dive computer time matches, so that we don't consider two parts of a dive that has been split to be obviously the same dive. Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Diffstat (limited to 'core/dive.c')
-rw-r--r--core/dive.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/core/dive.c b/core/dive.c
index 1ecfb923f..0936f685f 100644
--- a/core/dive.c
+++ b/core/dive.c
@@ -2701,7 +2701,7 @@ int match_one_dc(struct divecomputer *a, struct divecomputer *b)
* If they have different dive ID's on the same
* dive computer, that's a definite "same or not"
*/
- return a->diveid == b->diveid ? 1 : -1;
+ return a->diveid == b->diveid && a->when == b->when ? 1 : -1;
}
/*
@@ -3456,6 +3456,7 @@ static int split_dive_at(struct dive *dive, int a, int b)
*/
t = dc2->sample[0].time.seconds;
d2->when += t;
+ dc2->when += t;
for (i = 0; i < dc2->samples; i++)
dc2->sample[i].time.seconds -= t;