diff options
author | Robert C. Helling <helling@atdotde.de> | 2015-01-28 11:35:15 +0100 |
---|---|---|
committer | Dirk Hohndel <dirk@hohndel.org> | 2015-01-28 07:51:32 -0800 |
commit | 52b92ee03ba86fd77308aef6c62c51c68344bcb8 (patch) | |
tree | f9d91496eb5501cedf7156edadfad98a290ab153 /dive.c | |
parent | 991531d847cc39f39fcd9a02c9e6fcb12178a807 (diff) | |
download | subsurface-52b92ee03ba86fd77308aef6c62c51c68344bcb8.tar.gz |
Don't let the oxygen partial pressure drop below 0.
No oxygen at all is not quite enough for the average diver but this prevents
inifintie loops/extremely long deco when subsurface is used in pscr mode
with unrealistic values for pscr preferences.
Signed-off-by: Robert C. Helling <helling@atdotde.de>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Diffstat (limited to 'dive.c')
-rw-r--r-- | dive.c | 2 |
1 files changed, 2 insertions, 0 deletions
@@ -1683,6 +1683,8 @@ extern void fill_pressures(struct gas_pressures *pressures, const double amb_pre } else { if (divemode == PSCR) { /* The steady state approximation should be good enough */ pressures->o2 = get_o2(mix) / 1000.0 * amb_pressure - (1.0 - get_o2(mix) / 1000.0) * prefs.o2consumption / (prefs.bottomsac * prefs.pscr_ratio / 1000.0); + if (pressures->o2 < 0) // He's dead, Jim. + pressures->o2 = 0; if (get_o2(mix) != 1000) { pressures->he = (amb_pressure - pressures->o2) * get_he(mix) / (1000.0 - get_o2(mix)); pressures->n2 = (amb_pressure - pressures->o2) * (1000 - get_o2(mix) - get_he(mix)) / (1000.0 - get_o2(mix)); |