diff options
Diffstat (limited to 'core')
-rw-r--r-- | core/profile.c | 23 |
1 files changed, 22 insertions, 1 deletions
diff --git a/core/profile.c b/core/profile.c index 4e9ee88ee..4438154e3 100644 --- a/core/profile.c +++ b/core/profile.c @@ -472,6 +472,7 @@ struct plot_info calculate_max_limits_new(struct dive *dive, struct divecomputer int i = dc->samples; int lastdepth = 0; struct sample *s = dc->sample; + struct event *ev; while (--i >= 0) { int depth = s->depth.mm; @@ -501,6 +502,15 @@ struct plot_info calculate_max_limits_new(struct dive *dive, struct divecomputer lastdepth = depth; s++; } + + /* Make sure we can fit all events */ + ev = dc->events; + while (ev) { + if (ev->time.seconds > maxtime) + maxtime = ev->time.seconds; + ev = ev->next; + } + dc = dc->next; if (dc == NULL && !seen) { dc = given_dc; @@ -608,7 +618,6 @@ struct plot_data *populate_plot_entries(struct dive *dive, struct divecomputer * ev = ev->next; } - entry->sec = time; entry->depth = depth; @@ -652,6 +661,18 @@ struct plot_data *populate_plot_entries(struct dive *dive, struct divecomputer * break; } + /* Add any remaining events */ + while (ev) { + struct plot_data *entry = plot_data + idx; + int time = ev->time.seconds; + + if (time > lasttime) { + INSERT_ENTRY(ev->time.seconds, 0, 0); + lasttime = time; + } + ev = ev->next; + } + /* Add two final surface events */ plot_data[idx++].sec = lasttime + 1; plot_data[idx++].sec = lasttime + 2; |