diff options
-rw-r--r-- | dive.c | 9 | ||||
-rw-r--r-- | profile.c | 2 |
2 files changed, 7 insertions, 4 deletions
@@ -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; } @@ -1387,6 +1387,8 @@ void plot(struct graphics_context *gc, cairo_rectangle_int_t *drawing_area, stru int duration = dive->duration.seconds; int maxdepth = dive->maxdepth.mm; int asc_desc_time = dive->maxdepth.mm*60/9000; + if (asc_desc_time * 2 >= duration) + asc_desc_time = duration / 2; sample = fake; fake[1].time.seconds = asc_desc_time; fake[1].depth.mm = maxdepth; |