summaryrefslogtreecommitdiffstats
path: root/dive.c
diff options
context:
space:
mode:
authorGravatar Dirk Hohndel <dirk@hohndel.org>2013-02-12 12:34:22 -0800
committerGravatar Dirk Hohndel <dirk@hohndel.org>2013-02-12 12:34:22 -0800
commit1b548c071b50a8576e0a23125b95748c42d6d0ef (patch)
tree259e640a8dc63d9c504eb3d4f920f1ee05692415 /dive.c
parent9fa9ebcff2ab17eacefa82dd1ca2eb2a1ddd3523 (diff)
downloadsubsurface-1b548c071b50a8576e0a23125b95748c42d6d0ef.tar.gz
Set maxdepth correctly for dives with no samples
This showed up when suddenly some of the test dives no longer got merged when loaded twice. As I moved maxdepth up into the dive structure and added the code to fixup the data from what is in the divecomputer I missed the part where the function is exited early if there are no samples. This patch corrects that oversight. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Diffstat (limited to 'dive.c')
-rw-r--r--dive.c15
1 files changed, 8 insertions, 7 deletions
diff --git a/dive.c b/dive.c
index 7db239584..528172a40 100644
--- a/dive.c
+++ b/dive.c
@@ -661,14 +661,15 @@ static void fixup_dive_dc(struct dive *dive, struct divecomputer *dc)
asc_desc_time = duration/2;
dc->meandepth.mm = depth*(duration-asc_desc_time)/duration;
- return;
- }
-
- update_duration(&dc->duration, end - start);
- if (start != end)
- depthtime /= (end - start);
+ if (depth > maxdepth)
+ maxdepth = depth;
+ } else {
+ update_duration(&dc->duration, end - start);
+ if (start != end)
+ depthtime /= (end - start);
- update_depth(&dc->meandepth, depthtime);
+ update_depth(&dc->meandepth, depthtime);
+ }
update_temperature(&dc->watertemp, mintemp);
update_depth(&dc->maxdepth, maxdepth);
if (maxdepth > dive->maxdepth.mm)