summaryrefslogtreecommitdiffstats
path: root/core/qthelper.cpp
diff options
context:
space:
mode:
authorGravatar Rick Walsh <rickmwalsh@gmail.com>2016-05-22 11:00:22 +1000
committerGravatar Dirk Hohndel <dirk@hohndel.org>2016-05-28 14:24:10 -0700
commit8acbeed55584c21931238f9b4738e337919029b9 (patch)
tree69249c7bb4b1c68422a8d229b09782f9f7ba5f33 /core/qthelper.cpp
parent47a2e8b1d9bdd71b1b45036c533ba108d35b1eab (diff)
downloadsubsurface-8acbeed55584c21931238f9b4738e337919029b9.tar.gz
Add some gas mix validation to the planner
A few basic rules for gas validation: We can't have <0%, or >100% of either O2 or He O2 + He must not be >100% Switch depth can't be <0% This places limits on user-input values Signed-off-by: Rick Walsh <rickmwalsh@gmail.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Diffstat (limited to 'core/qthelper.cpp')
-rw-r--r--core/qthelper.cpp9
1 files changed, 9 insertions, 0 deletions
diff --git a/core/qthelper.cpp b/core/qthelper.cpp
index 24c51d2b9..d6a6c2579 100644
--- a/core/qthelper.cpp
+++ b/core/qthelper.cpp
@@ -1253,6 +1253,8 @@ depth_t string_to_depth(const char *str)
QString local_m = QObject::tr("m");
depth_t depth;
+ if (value < 0)
+ value = 0;
if (rest.startsWith("m") || rest.startsWith(local_m))
goto m;
if (rest.startsWith("ft") || rest.startsWith(local_ft))
@@ -1328,6 +1330,13 @@ fraction_t string_to_fraction(const char *str)
fraction_t fraction;
fraction.permille = rint(value * 10);
+ /*
+ * Don't permit values less than zero or greater than 100%
+ */
+ if (fraction.permille < 0)
+ fraction.permille = 0;
+ else if (fraction.permille > 1000)
+ fraction.permille = 1000;
return fraction;
}