X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=dive.c;h=aee09d53a8b37796fc6f2fa0e448f92102be745e;hb=ed1ce8ebc8590533291a9c5d6460f8d1c9f857dd;hp=f5d0828015e2b64990a390d877839e43335ffd48;hpb=e8ec3df371f0496a52ebdc463245d7b9df3be6ff;p=ext%2Fsubsurface.git diff --git a/dive.c b/dive.c index f5d0828..aee09d5 100644 --- a/dive.c +++ b/dive.c @@ -472,8 +472,20 @@ struct dive *fixup_dive(struct dive *dive) cyl->sample_end.mbar = 0; } } - if (end < 0) + if (end < 0) { + /* Assume an ascent/descent rate of 9 m/min */ + int depth = dive->maxdepth.mm; + int asc_desc_time = depth*60/9000; + int duration = dive->duration.seconds; + + /* Protect against insane dives - make mean be half of max */ + if (duration <= asc_desc_time) { + duration = 2; + asc_desc_time = 1; + } + dive->meandepth.mm = depth*(duration-asc_desc_time)/duration; return dive; + } update_duration(&dive->duration, end - start); if (start != end)