mirror of
https://github.com/subsurface/subsurface.git
synced 2024-11-30 22:20:21 +00:00
Fix up end conditions for dives
We used to have the dive plot have two "filler" entries at the beginning and the end, and indeed that is how they are allocated. However, we fix up "pi->nr" later to be "lastindex+1", where "lastindex" is the index of the time we surface. So when we loop over the plot entries, we actually need to loop all the way to the end: use "i < pi->nr" instead of "i < pi->nr-2". We still do have the two extra filler entries at the beginning, though. So depending on the loop, we might want to start at entry 2. Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
This commit is contained in:
parent
7c1deb37c7
commit
ceed8b6bc9
1 changed files with 4 additions and 5 deletions
|
@ -660,7 +660,7 @@ static void plot_cylinder_pressure_text(struct graphics_context *gc, struct plot
|
|||
return;
|
||||
|
||||
/* only loop over the actual events from the dive computer */
|
||||
for (i = 2; i < pi->nr - 2; i++) {
|
||||
for (i = 2; i < pi->nr; i++) {
|
||||
entry = pi->entry + i;
|
||||
|
||||
if (!entry->same_cylinder) {
|
||||
|
@ -887,8 +887,9 @@ static void fill_missing_tank_pressures(struct dive *dive, struct plot_info *pi,
|
|||
for (cyl = 0; cyl < MAX_CYLINDERS; cyl++) {
|
||||
cur_pr[cyl] = track_pr[cyl]->start;
|
||||
}
|
||||
/* The first two and last two entries are "fillers" */
|
||||
for (i = 2; i < pi->nr-2; i++) {
|
||||
|
||||
/* The first two are "fillers" */
|
||||
for (i = 2; i < pi->nr; i++) {
|
||||
entry = pi->entry + i;
|
||||
if (SENSOR_PRESSURE(entry)) {
|
||||
cur_pr[entry->cylinderindex] = SENSOR_PRESSURE(entry);
|
||||
|
@ -1084,8 +1085,6 @@ static struct plot_info *create_plot_info(struct dive *dive, int nr_samples, str
|
|||
pr_track->end = pr;
|
||||
}
|
||||
}
|
||||
if (lastdepth)
|
||||
lastindex = i + 2;
|
||||
/* Fill in the last two entries with empty values but valid times */
|
||||
i = nr_samples + 2;
|
||||
pi->entry[i].sec = sec + 20;
|
||||
|
|
Loading…
Reference in a new issue