aboutsummaryrefslogtreecommitdiffstats
path: root/core/dive.c
diff options
context:
space:
mode:
authorGravatar Linus Torvalds <torvalds@linux-foundation.org>2017-07-20 14:39:02 -0700
committerGravatar Dirk Hohndel <dirk@hohndel.org>2017-07-20 17:32:54 -0700
commit11a0c0cc701806ccec975c67d27dec97fbb13b1f (patch)
tree15a3ace16588b80a88fea76cec30386414bfc3f7 /core/dive.c
parent94d8abd1a292ac0b02064c906da3a66ccf9e6737 (diff)
downloadsubsurface-11a0c0cc701806ccec975c67d27dec97fbb13b1f.tar.gz
Unify sample pressure and o2pressure as pressure[2] array
We currently carry two pressures around for all the samples and plot info, but the second pressure is reserved for CCR dives as the O2 cylinder pressure. That's kind of annoying when we *could* use it for regular sidemount dives as the secondary pressure. So start prepping for that instead: don't make it "pressure" and "o2pressure", make it just be an array of two pressure values. NOTE! This is purely mindless prepwork. It literally just does a search-and-replace, keeping the exact same semantics, so "pressure[1]" is still just O2 pressure. But at some future date, we can now start using it for a second sensor value for sidemount instead. Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Diffstat (limited to 'core/dive.c')
-rw-r--r--core/dive.c22
1 files changed, 11 insertions, 11 deletions
diff --git a/core/dive.c b/core/dive.c
index e71249413..229a04eba 100644
--- a/core/dive.c
+++ b/core/dive.c
@@ -1359,17 +1359,17 @@ static void simplify_dc_pressures(struct divecomputer *dc)
for (i = 0; i < dc->samples; i++) {
struct sample *sample = dc->sample + i;
- int pressure = sample->cylinderpressure.mbar;
- int o2_pressure = sample->o2cylinderpressure.mbar;
+ int pressure = sample->pressure[0].mbar;
+ int o2_pressure = sample->pressure[1].mbar;
int index;
index = sample->sensor;
if (index == lastindex) {
/* Remove duplicate redundant pressure information */
if (pressure == lastpressure)
- sample->cylinderpressure.mbar = 0;
+ sample->pressure[0].mbar = 0;
if (o2_pressure == lasto2pressure)
- sample->o2cylinderpressure.mbar = 0;
+ sample->pressure[1].mbar = 0;
}
lastindex = index;
lastpressure = pressure;
@@ -1423,8 +1423,8 @@ static void fixup_dive_pressures(struct dive *dive, struct divecomputer *dc)
if (sample->depth.mm < SURFACE_THRESHOLD)
continue;
- fixup_start_pressure(dive, sample->sensor, sample->cylinderpressure);
- fixup_start_pressure(dive, o2index, sample->o2cylinderpressure);
+ fixup_start_pressure(dive, sample->sensor, sample->pressure[0]);
+ fixup_start_pressure(dive, o2index, sample->pressure[1]);
}
/* ..and from the end for ending pressures */
@@ -1434,8 +1434,8 @@ static void fixup_dive_pressures(struct dive *dive, struct divecomputer *dc)
if (sample->depth.mm < SURFACE_THRESHOLD)
continue;
- fixup_end_pressure(dive, sample->sensor, sample->cylinderpressure);
- fixup_end_pressure(dive, o2index, sample->o2cylinderpressure);
+ fixup_end_pressure(dive, sample->sensor, sample->pressure[0]);
+ fixup_end_pressure(dive, o2index, sample->pressure[1]);
}
simplify_dc_pressures(dc);
@@ -1713,8 +1713,8 @@ static void merge_samples(struct divecomputer *res, struct divecomputer *a, stru
sample.depth = as->depth;
if (as->temperature.mkelvin)
sample.temperature = as->temperature;
- if (as->cylinderpressure.mbar)
- sample.cylinderpressure = as->cylinderpressure;
+ if (as->pressure[0].mbar)
+ sample.pressure[0] = as->pressure[0];
if (as->sensor)
sample.sensor = as->sensor;
if (as->cns)
@@ -2625,7 +2625,7 @@ static int same_sample(struct sample *a, struct sample *b)
return 0;
if (a->temperature.mkelvin != b->temperature.mkelvin)
return 0;
- if (a->cylinderpressure.mbar != b->cylinderpressure.mbar)
+ if (a->pressure[0].mbar != b->pressure[0].mbar)
return 0;
return a->sensor == b->sensor;
}