fix: merge_pressure does not calculate starting pressures correctly

The existing logic correctly calculates the minimum (ie, ending) pressure, but not the maximum
(ie starting) pressure.

For example, 2 tanks A and B with manual pressures (same tank on subsequent dives, which were
then merged):
A: 205 - 84
B: 83 - 55

When merging the starting pressures, the call is : merge_pressure(205, 0, 83, 0, false)

The final comparison is:
  if(false && 205 < 83) return 205;
  else return 83;

-> So 83 is returned even though 205 should have been.

Signed-off-by: Michael Werle <micha@michaelwerle.com>
This commit is contained in:
Michael Werle 2023-08-07 16:34:55 +09:00 committed by Berthold Stoeger
parent 26f20b805d
commit fae68b7a68

View file

@ -1852,10 +1852,9 @@ static pressure_t merge_pressures(pressure_t a, pressure_t sample_a, pressure_t
a = b;
if (!b.mbar)
b = a;
if (take_min && a.mbar < b.mbar)
return a;
else
return b;
if (take_min)
return a.mbar < b.mbar? a : b;
return a.mbar > b.mbar? a : b;
}
/*