X-Git-Url: http://git.tdb.fi/?p=ext%2Fsubsurface.git;a=blobdiff_plain;f=dive.c;h=54784cdbabfb01fbb5c5a8db539cdc481f20c613;hp=aee09d53a8b37796fc6f2fa0e448f92102be745e;hb=HEAD;hpb=1a05f34ae89d35f6ece12dba7b6ab5f60df98705 diff --git a/dive.c b/dive.c index aee09d5..54784cd 100644 --- a/dive.c +++ b/dive.c @@ -478,11 +478,12 @@ struct dive *fixup_dive(struct dive *dive) 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) { + /* Some sanity checks against insane dives */ + if (duration < 2) duration = 2; - asc_desc_time = 1; - } + if (asc_desc_time * 2 >= duration) + asc_desc_time = duration/2; + dive->meandepth.mm = depth*(duration-asc_desc_time)/duration; return dive; }