mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +00:00
Fix manual pressures for cylinders with no gas switches
"If it hasn't been tested, it doesn't work". All my testing of the multiple sensor pressures have been with some reasonably "interesting" dives: they actually *have* sensor pressures. But that test coverage means that I missed the truly trivial case of just having manual pressures for a single cylinder. Because there's only a single cylinder, it doesn't have any cylinder changes, and because there were no cylinder changes, it never filled in the use range for that cylinder. So then it never showed the pressure profile at all. Duh. Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
parent
df1bd0015a
commit
92b1c318bd
1 changed files with 12 additions and 13 deletions
|
@ -822,6 +822,10 @@ static void setup_gas_sensor_pressure(struct dive *dive, struct divecomputer *dc
|
|||
unsigned int first[MAX_CYLINDERS] = { 0, };
|
||||
unsigned int last[MAX_CYLINDERS] = { 0, };
|
||||
struct divecomputer *secondary;
|
||||
int endtime = dc->samples ? dc->sample[dc->samples-1].time.seconds : dive->duration.seconds;
|
||||
|
||||
for (i = 0; i < MAX_CYLINDERS; i++)
|
||||
last[i] = endtime;
|
||||
|
||||
for (ev = get_next_event(dc->events, "gaschange"); ev != NULL; ev = get_next_event(ev->next, "gaschange")) {
|
||||
int cyl = ev->gas.index;
|
||||
|
@ -836,27 +840,22 @@ static void setup_gas_sensor_pressure(struct dive *dive, struct divecomputer *dc
|
|||
|
||||
last[cyl] = sec;
|
||||
if (!seen[cyl]) {
|
||||
int endtime = sec;
|
||||
if (dc->samples)
|
||||
endtime = dc->sample[dc->samples-1].time.seconds;
|
||||
|
||||
// The end time may be updated by a subsequent cylinder change
|
||||
first[cyl] = sec;
|
||||
last[cyl] = endtime;
|
||||
seen[cyl] = 1;
|
||||
}
|
||||
}
|
||||
if (prev >= 0)
|
||||
last[prev] = endtime;
|
||||
|
||||
for (i = 0; i < MAX_CYLINDERS; i++) {
|
||||
if (seen[i]) {
|
||||
cylinder_t *cyl = dive->cylinder + i;
|
||||
int start = cyl->start.mbar;
|
||||
int end = cyl->end.mbar;
|
||||
cylinder_t *cyl = dive->cylinder + i;
|
||||
int start = cyl->start.mbar;
|
||||
int end = cyl->end.mbar;
|
||||
|
||||
if (start)
|
||||
add_plot_pressure(pi, first[i], i, start);
|
||||
if (end)
|
||||
add_plot_pressure(pi, last[i], i, end);
|
||||
if (start && end) {
|
||||
add_plot_pressure(pi, first[i], i, start);
|
||||
add_plot_pressure(pi, last[i], i, end);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue