diff options
author | Linus Torvalds <torvalds@linux-foundation.org> | 2013-02-24 11:07:27 -0800 |
---|---|---|
committer | Dirk Hohndel <dirk@hohndel.org> | 2013-02-24 11:25:44 -0800 |
commit | b62e63650a3794a90f7af1aaee62b7fa7780b455 (patch) | |
tree | 1f76efb199503affffa920b12386941b77d1d58d /dive.c | |
parent | 6d548d20285bce74f1a75f2623d55094871c1a81 (diff) | |
download | subsurface-b62e63650a3794a90f7af1aaee62b7fa7780b455.tar.gz |
Fix SAC calculations for dives without any samples
We computed a made-up average depth based on the maximum depth, and used
that. That's questionable even if we didn't have any explicit average
depth to begin with, but it's particularly wrong if we did have an
explicit average depth to use.
Now, admittedly we have no way to actually create fake dives like this
with a particular average depth, so this really doesn't make any
difference in real life. But we should do this right.
Also, make the XML be in the format that subsurface actually saves
things in (mainly things like cylinder sizes having an extra decimal
place, but also ordering of XML elements).
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 | 3 |
1 files changed, 2 insertions, 1 deletions
@@ -678,7 +678,8 @@ static void fixup_dive_dc(struct dive *dive, struct divecomputer *dc) if (asc_desc_time * 2 >= duration) asc_desc_time = duration/2; - dc->meandepth.mm = depth*(duration-asc_desc_time)/duration; + if (!dc->meandepth.mm) + dc->meandepth.mm = depth*(duration-asc_desc_time)/duration; if (depth > maxdepth) maxdepth = depth; } else { |