summaryrefslogtreecommitdiff
path: root/src/control.cc
diff options
context:
space:
mode:
authorVicnet <vo.publique@gmail.com>2013-10-07 14:02:43 (GMT)
committerVicnet <vo.publique@gmail.com>2013-10-07 14:04:43 (GMT)
commiteb27a0277f1eb08e947f5d4e4036f5fe13dfe086 (patch)
treea57f9de205e4b9a2f8d7849690c68ac37940b637 /src/control.cc
parent9bc73ac106a78398b744c2cd6c997055d8d2de9d (diff)
factorize Value::RangeType calculation and correct error
Diffstat (limited to 'src/control.cc')
-rw-r--r--src/control.cc5
1 files changed, 3 insertions, 2 deletions
diff --git a/src/control.cc b/src/control.cc
index db12f71..c50402f 100644
--- a/src/control.cc
+++ b/src/control.cc
@@ -79,7 +79,7 @@ void ControlModule::for_eval(AbstractNode &node, const ModuleInstantiation &inst
if (it_values.type() == Value::RANGE) {
Value::RangeType range = it_values.toRange();
range.normalize();
- if ((range.step > 0) && (range.begin-range.end)/range.step < 10000) {
+ if (range.nbsteps()<10000) {
for (double i = range.begin; i <= range.end; i += range.step) {
c.set_variable(it_name, Value(i));
for_eval(node, inst, l+1, &c, evalctx);
@@ -147,6 +147,7 @@ AbstractNode* ControlModule::getChild(const Value& value, const EvalContext* mod
// (e.g. first child of difference is invalid)
PRINTB("WARNING: Children index (%d) out of bounds (%d children)"
, n % modulectx->numChildren());
+ return NULL;
}
// OK
return modulectx->getChild(n)->evaluate(modulectx);
@@ -226,7 +227,7 @@ AbstractNode *ControlModule::instantiate(const Context* /*ctx*/, const ModuleIns
AbstractNode* node = new AbstractNode(inst);
Value::RangeType range = value.toRange();
range.normalize();
- if ((range.step>0) && ((range.begin-range.end)/range.step>=10000)) {
+ if (range.nbsteps()>=10000) {
PRINTB("WARNING: Bad range parameter for children: too many elements (%d).", (int)((range.begin-range.end)/range.step));
return NULL;
}
contact: Jan Huwald // Impressum