X-Git-Url: http://git.tdb.fi/?p=ext%2Fsubsurface.git;a=blobdiff_plain;f=dive.c;h=54784cdbabfb01fbb5c5a8db539cdc481f20c613;hp=f5d0828015e2b64990a390d877839e43335ffd48;hb=HEAD;hpb=9b72217f79f29313d30c87c55f533cc606da6a8f diff --git a/dive.c b/dive.c index f5d0828..54784cd 100644 --- a/dive.c +++ b/dive.c @@ -472,8 +472,21 @@ 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; + + /* Some sanity checks against insane dives */ + if (duration < 2) + duration = 2; + if (asc_desc_time * 2 >= duration) + asc_desc_time = duration/2; + + dive->meandepth.mm = depth*(duration-asc_desc_time)/duration; return dive; + } update_duration(&dive->duration, end - start); if (start != end)