X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=dive.c;h=aee09d53a8b37796fc6f2fa0e448f92102be745e;hb=ed1ce8ebc8590533291a9c5d6460f8d1c9f857dd;hp=a420a3ef638927cd39c60ffe69f5fa37a9bbfea3;hpb=19621bf481c68955184c11dd407c59af4a05130e;p=ext%2Fsubsurface.git diff --git a/dive.c b/dive.c index a420a3e..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) @@ -486,6 +498,7 @@ struct dive *fixup_dive(struct dive *dive) add_people(dive->buddy); add_people(dive->divemaster); add_location(dive->location); + add_suit(dive->suit); for (i = 0; i < MAX_CYLINDERS; i++) { cylinder_t *cyl = dive->cylinder + i; add_cylinder_description(&cyl->type); @@ -703,6 +716,7 @@ struct dive *try_to_merge(struct dive *a, struct dive *b) MERGE_TXT(res, a, b, buddy); MERGE_TXT(res, a, b, divemaster); MERGE_MAX(res, a, b, rating); + MERGE_TXT(res, a, b, suit); MERGE_MAX(res, a, b, number); MERGE_MAX(res, a, b, maxdepth.mm); res->meandepth.mm = 0;