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>
This commit is contained in:
Linus Torvalds 2013-02-24 11:07:27 -08:00 committed by Dirk Hohndel
parent 6d548d2028
commit b62e63650a
2 changed files with 22 additions and 11 deletions

3
dive.c
View file

@ -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 {