diff options
author | Linus Torvalds <torvalds@linux-foundation.org> | 2015-09-22 12:32:27 -0700 |
---|---|---|
committer | Dirk Hohndel <dirk@hohndel.org> | 2015-09-22 19:36:54 -0700 |
commit | 34da4801f45c6fb06d3a7b55029fc4ebd702a6e6 (patch) | |
tree | 9272adb2fc49e91d2dad4fc37f1c1a71c68e2a48 /dive.h | |
parent | 000a93fb64d92729c51762e1483d36859d442e9d (diff) | |
download | subsurface-34da4801f45c6fb06d3a7b55029fc4ebd702a6e6.tar.gz |
Be much more careful about merging dives
This patch changes the dive merging to be much more careful about
things, because it turns out that we had several small oddities that
caused big merge issues.
The oddities are:
- the dive "duration" is actually how long we spend under water.
But that means that when we do "dive->when + dive.duration.seconds"
to calculate the end of the dive, that is nonsensical if you came up
to the surface in the middle of a dive.
Now, normally you don't see profiles like that, but once you start
merging dives together, it can go from "small detail" to "dominant
factor".
- We have two different cases of merging: the automatic "merge new dive
computer download if it looks like the same dive" (which always has a
merge offset of 0, since we merge it as a new dive computer) and the
"merge two different dives into one longer dive.
The code assumed that it could look at the "downloaded" flag for the
dive to check one or the other, but that doesn't really work.
Reading a dive from an XML file isn't any different from downloading
it.
So we need to change the logic to determine what kind of merge it is
to actually check the passed-in time offset.
With this, Stuart Vernon's test-case of eight dives with short surface
intervals in between end up merging correctly into one dive.
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Reported-by: Stuart Vernon <stuartv@force2.net>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Diffstat (limited to 'dive.h')
-rw-r--r-- | dive.h | 2 |
1 files changed, 2 insertions, 0 deletions
@@ -562,6 +562,8 @@ static inline struct divecomputer *get_dive_dc(struct dive *dive, int nr) return dc; } +extern timestamp_t dive_endtime(const struct dive *dive); + extern void make_first_dc(void); extern int count_divecomputers(void); extern void delete_current_divecomputer(void); |