aboutsummaryrefslogtreecommitdiffstats
path: root/profile.c
diff options
context:
space:
mode:
authorGravatar Dirk Hohndel <dirk@hohndel.org>2011-11-09 07:41:41 -0800
committerGravatar Dirk Hohndel <dirk@hohndel.org>2011-11-09 07:53:10 -0800
commite38eb77e30c2d0d06eb61db0cd1bdf3f5e164e8d (patch)
tree498bd104465ed888b48ccac2bbaadbb69920cda8 /profile.c
parent4b735521e2561fe6d03f9f94122fbdc58f48e4a5 (diff)
downloadsubsurface-e38eb77e30c2d0d06eb61db0cd1bdf3f5e164e8d.tar.gz
Correctly plot dives ending below the surface
I thought we had fixed this before - but I guess it got broken again somewhere. We now make sure that the plot_info ends on an entry with depth 0. Added test14 to verify the fix. Also fixed cut'n'paste errors in a few test dive files. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Diffstat (limited to 'profile.c')
-rw-r--r--profile.c9
1 files changed, 6 insertions, 3 deletions
diff --git a/profile.c b/profile.c
index 173032a13..60e0f4215 100644
--- a/profile.c
+++ b/profile.c
@@ -1098,7 +1098,7 @@ static struct plot_info *create_plot_info(struct dive *dive, int nr_samples, str
entry->temperature = sample->temperature.mkelvin;
if (depth || lastdepth)
- lastindex = i+pi_idx;
+ lastindex = i + pi_idx;
lastdepth = depth;
if (depth > pi->maxdepth)
@@ -1162,9 +1162,12 @@ static struct plot_info *create_plot_info(struct dive *dive, int nr_samples, str
i = nr + 2;
pi->entry[i].sec = sec + 20;
pi->entry[i+1].sec = sec + 40;
- /* the number of actual entries - we may have allocated more if there
- * were gas change events, but this is how many were filled */
+ /* the number of actual entries - some computers have lots of
+ * depth 0 samples at the end of a dive, we want to make sure
+ * we have exactly one of them at the end */
pi->nr = lastindex+1;
+ while (pi->nr <= i+2 && pi->entry[pi->nr-1].depth > 0)
+ pi->nr++;
pi->maxtime = pi->entry[lastindex].sec;
pi->endpressure = pi->minpressure = dive->cylinder[0].end.mbar;