aboutsummaryrefslogtreecommitdiffstats
path: root/core
diff options
context:
space:
mode:
authorGravatar Berthold Stoeger <bstoeger@mail.tuwien.ac.at>2021-09-13 20:48:18 +0200
committerGravatar Dirk Hohndel <dirk@hohndel.org>2021-09-22 09:11:00 -0700
commitd9c77a27da83d7f00254edd405406326254faae2 (patch)
tree3cedeb11b08f000a55618b097300d461ae17b109 /core
parentf50585a906bd05d71e8b1d5cfc90b2e1959a6ced (diff)
downloadsubsurface-d9c77a27da83d7f00254edd405406326254faae2.tar.gz
core: properly clear pressure data of invalid sensors
When we found an invalid sensor (referring to a non existing cylinder) in fixup_dive() the sensor-id was set to NO_SENSOR. This led to invalid XML files, because the code decides to switch into legacy mode. However, there are two pressure readings, which is invalid in legacy mode. Therefore, also clear the pressure data. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Diffstat (limited to 'core')
-rw-r--r--core/dive.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/core/dive.c b/core/dive.c
index c97e1ba11..414ad30f2 100644
--- a/core/dive.c
+++ b/core/dive.c
@@ -1213,8 +1213,10 @@ 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)
+ if (s->sensor[j] < 0 || s->sensor[j] >= nr_cylinders) {
s->sensor[j] = NO_SENSOR;
+ s->pressure[j].mbar = 0;
+ }
}
}
}