diff options
author | Linus Torvalds <torvalds@linux-foundation.org> | 2012-11-11 07:49:19 +0100 |
---|---|---|
committer | Dirk Hohndel <dirk@hohndel.org> | 2012-11-11 10:48:14 +0100 |
commit | 8514ec8723542b11a555af2d204a4a7b66b062cc (patch) | |
tree | f4217ee9f8254a9c87a021ed989e5088c59873da /dive.c | |
parent | cda1b73bf68d1802c32416bce3be0ef84137002e (diff) | |
download | subsurface-8514ec8723542b11a555af2d204a4a7b66b062cc.tar.gz |
Support merging of two adjacent dives
This introduces the notion of merging two disjoint dives: you can select
two dives from the dive list, and if the selection is exactly two dives,
and they are adjacent (and share the same dive trip), we support the
notion of merging the dives into one dive.
The most common reason for this is an extended surface event, which made
the dive computer decide that the dive was ended, but maybe you were
just waiting for a buddy or a student at the surface, and you want to
stitch together two dives into one.
There are still details to be sorted out: my Suunto dive computers don't
actually do surface samples at the beginning or end of the dive, so when
you stitch two dives together, the profile ends up being this odd "a
couple of feet under water between the two parts of the dive" thing.
But that's an independent thing from the actual merging logic, and I'll
work on that separately.
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Diffstat (limited to 'dive.c')
-rw-r--r-- | dive.c | 9 |
1 files changed, 3 insertions, 6 deletions
@@ -811,15 +811,13 @@ static void merge_equipment(struct dive *res, struct dive *a, struct dive *b) * The 'next' dive is not involved in the dive merging, but is the dive * that will be the next dive after the merged dive. */ -static void pick_and_delete_trip(struct dive *res, struct dive *pick, struct dive *remove) +static void pick_trip(struct dive *res, struct dive *pick) { tripflag_t tripflag = pick->tripflag; dive_trip_t *trip = pick->divetrip; res->tripflag = tripflag; add_dive_to_trip(res, trip); - remove_dive_from_trip(pick); - remove_dive_from_trip(remove); } /* @@ -860,10 +858,9 @@ static void merge_trip(struct dive *res, struct dive *a, struct dive *b) goto pick_b; pick_a: - pick_and_delete_trip(res, a, b); - return; + b = a; pick_b: - pick_and_delete_trip(res, b, a); + pick_trip(res, b); } /* |