X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=dive.c;h=deb72fc804225712edf164d52ab1a4fca5ba1d93;hb=dbdd42b31f73ad8e8117d5b2a5b4ac4e061bf202;hp=a1ef28c8e3d0deb9bceb686215ce5dfbaf0a53a2;hpb=a6f6e8d6ff06d03fc01d8a6e7f50240e405b7ea6;p=ext%2Fsubsurface.git diff --git a/dive.c b/dive.c index a1ef28c..deb72fc 100644 --- a/dive.c +++ b/dive.c @@ -154,8 +154,12 @@ static void fixup_pressure(struct dive *dive, struct sample *sample) cyl = dive->cylinder + index; if (!cyl->start.mbar) cyl->start.mbar = pressure; - if (!cyl->end.mbar || pressure < cyl->end.mbar) - cyl->end.mbar = pressure; + /* we need to handle the user entering beginning and end tank pressures + * - maybe even IF we have samples. But for now if we have air pressure + * data in the samples, we use that instead of the minimum + * if (!cyl->end.mbar || pressure < cyl->end.mbar) + */ + cyl->end.mbar = pressure; } struct dive *fixup_dive(struct dive *dive) @@ -222,6 +226,7 @@ struct dive *fixup_dive(struct dive *dive) #define MERGE_MAX(res, a, b, n) res->n = MAX(a->n, b->n) #define MERGE_MIN(res, a, b, n) res->n = (a->n)?(b->n)?MIN(a->n, b->n):(a->n):(b->n) #define MERGE_TXT(res, a, b, n) res->n = merge_text(a->n, b->n) +#define MERGE_NONZERO(res, a, b, n) res->n = a->n ? a->n : b->n static struct dive *add_sample(struct sample *sample, int time, struct dive *dive) { @@ -405,12 +410,14 @@ struct dive *try_to_merge(struct dive *a, struct dive *b) int i; struct dive *res; - if (a->when != b->when) + if ((a->when >= b->when + 60) || (a->when <= b->when - 60)) return NULL; res = alloc_dive(); res->when = a->when; + MERGE_NONZERO(res, a, b, latitude); + MERGE_NONZERO(res, a, b, longitude); MERGE_TXT(res, a, b, location); MERGE_TXT(res, a, b, notes); MERGE_TXT(res, a, b, buddy);