]> git.tdb.fi Git - ext/subsurface.git/commitdiff
dive parsing: enforce maxdepth and dive duration
authorLinus Torvalds <torvalds@linux-foundation.org>
Wed, 31 Aug 2011 21:36:53 +0000 (14:36 -0700)
committerLinus Torvalds <torvalds@linux-foundation.org>
Wed, 31 Aug 2011 21:36:53 +0000 (14:36 -0700)
If we see samples from past the dive duration, update the dive duration.
Likewise with maxdepth.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
parse.c

diff --git a/parse.c b/parse.c
index 58476ef155e90c506d940a8f01cf99b10010f601..58d446db099c46f408a3c27d35bdfec99e249d40 100644 (file)
--- a/parse.c
+++ b/parse.c
@@ -444,9 +444,18 @@ static void sample_start(void)
 
 static void sample_end(void)
 {
-       sample = NULL;
        if (!dive)
                return;
+
+       if (sample->time.seconds > dive->duration.seconds) {
+               if (sample->depth.mm)
+                       dive->duration = sample->time;
+       }
+
+       if (sample->depth.mm > dive->maxdepth.mm)
+               dive->maxdepth.mm = sample->depth.mm;
+
+       sample = NULL;
        dive->samples++;
 }