summaryrefslogtreecommitdiffstats
path: root/core/dive.c
diff options
context:
space:
mode:
Diffstat (limited to 'core/dive.c')
-rw-r--r--core/dive.c14
1 files changed, 14 insertions, 0 deletions
diff --git a/core/dive.c b/core/dive.c
index 36b1376fa..e96036611 100644
--- a/core/dive.c
+++ b/core/dive.c
@@ -1208,6 +1208,17 @@ static void fixup_no_o2sensors(struct divecomputer *dc)
}
}
+static void fixup_dc_sample_sensors(struct divecomputer *dc, int nr_cylinders)
+{
+ for (int i = 0; i < dc->samples; i++) {
+ struct sample *s = dc->sample + i;
+ for (int j = 0; j < MAX_SENSORS; j++) {
+ if (s->sensor[j] < 0 || s->sensor[j] >= nr_cylinders)
+ s->sensor[j] = NO_SENSOR;
+ }
+ }
+}
+
static void fixup_dive_dc(struct dive *dive, struct divecomputer *dc)
{
/* Fixup duration and mean depth */
@@ -1228,6 +1239,9 @@ static void fixup_dive_dc(struct dive *dive, struct divecomputer *dc)
/* Fix up cylinder pressures based on DC info */
fixup_dive_pressures(dive, dc);
+ /* Fix up cylinder ids in pressure sensors */
+ fixup_dc_sample_sensors(dc, dive->cylinders.nr);
+
fixup_dc_events(dc);
/* Fixup CCR / PSCR dives with o2sensor values, but without no_o2sensors */