mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +00:00
Don't show cylinder pressures for other dive computers
Stefan Fuchs points out that sometimes you get cylinder duplication when you merge dives, particularly with a planned dive. For example, if we had different manual pressures in the two different dives, the cylinders will be kept separate. But that also means that we don't want to plot the pressures from those other cylinders that came from another dive and are now associated with another dive computer. Change the "seen" logic for the cylinder to ignore cylinders that are only mentioned by other dive computers than the active one. Reported-by: Stefan Fuchs <sfuchs@gmx.de> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
This commit is contained in:
parent
2e82a5d2ed
commit
7fa5fcfa1d
1 changed files with 36 additions and 6 deletions
|
@ -802,7 +802,7 @@ static void populate_secondary_sensor_data(struct divecomputer *dc, struct plot_
|
|||
* This adds a pressure entry to the plot_info based on the gas change
|
||||
* information and the manually filled in pressures.
|
||||
*/
|
||||
static void add_plot_pressure(struct plot_info *pi, int time, int cyl, int mbar)
|
||||
static void add_plot_pressure(struct plot_info *pi, int time, int cyl, pressure_t p)
|
||||
{
|
||||
struct plot_data *entry;
|
||||
for (int i = 0; i < pi->nr; i++) {
|
||||
|
@ -811,14 +811,14 @@ static void add_plot_pressure(struct plot_info *pi, int time, int cyl, int mbar)
|
|||
if (entry->sec >= time)
|
||||
break;
|
||||
}
|
||||
SENSOR_PRESSURE(entry, cyl) = mbar;
|
||||
SENSOR_PRESSURE(entry, cyl) = p.mbar;
|
||||
}
|
||||
|
||||
static void setup_gas_sensor_pressure(struct dive *dive, struct divecomputer *dc, struct plot_info *pi)
|
||||
{
|
||||
int prev, i;
|
||||
struct event *ev;
|
||||
unsigned int seen[MAX_CYLINDERS] = { 0, };
|
||||
int seen[MAX_CYLINDERS] = { 0, };
|
||||
unsigned int first[MAX_CYLINDERS] = { 0, };
|
||||
unsigned int last[MAX_CYLINDERS] = { 0, };
|
||||
struct divecomputer *secondary;
|
||||
|
@ -847,14 +847,44 @@ static void setup_gas_sensor_pressure(struct dive *dive, struct divecomputer *dc
|
|||
}
|
||||
last[prev] = INT_MAX;
|
||||
|
||||
// Fill in "seen[]" array - mark cylinders we're not interested
|
||||
// in as negative.
|
||||
for (i = 0; i < MAX_CYLINDERS; i++) {
|
||||
cylinder_t *cyl = dive->cylinder + i;
|
||||
int start = cyl->start.mbar;
|
||||
int end = cyl->end.mbar;
|
||||
|
||||
if (start && end && start != end) {
|
||||
add_plot_pressure(pi, first[i], i, start);
|
||||
add_plot_pressure(pi, last[i], i, end);
|
||||
/*
|
||||
* Fundamentally uninteresting?
|
||||
*
|
||||
* A dive computer with no pressure data isn't interesting
|
||||
* to plot pressures for even if we've seen it..
|
||||
*/
|
||||
if (!start || !end || start == end) {
|
||||
seen[i] = -1;
|
||||
continue;
|
||||
}
|
||||
|
||||
/* If we've seen it, we're definitely interested */
|
||||
if (seen[i])
|
||||
continue;
|
||||
|
||||
/* If it's only mentioned by other dc's, ignore it */
|
||||
for_each_dc(dive, secondary) {
|
||||
if (has_gaschange_event(dive, secondary, i)) {
|
||||
seen[i] = -1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
for (i = 0; i < MAX_CYLINDERS; i++) {
|
||||
if (seen[i] >= 0) {
|
||||
cylinder_t *cyl = dive->cylinder + i;
|
||||
|
||||
add_plot_pressure(pi, first[i], i, cyl->start);
|
||||
add_plot_pressure(pi, last[i], i, cyl->end);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue