From b4b9d3a4b7bf0d80e971551be81f7d8196919157 Mon Sep 17 00:00:00 2001 From: James Turner Date: Thu, 27 May 2010 15:19:04 +0100 Subject: [PATCH] Support constant true and false values in conditions. --- simgear/props/condition.cxx | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/simgear/props/condition.cxx b/simgear/props/condition.cxx index 20321052..85c539cf 100644 --- a/simgear/props/condition.cxx +++ b/simgear/props/condition.cxx @@ -41,6 +41,18 @@ private: SGConstPropertyNode_ptr _node; }; +/** + * Condition with constant value + * + */ +class SGConstantCondition : public SGCondition +{ +public: + SGConstantCondition (bool v) : _value(v) { ; } + virtual bool test () const { return _value; } +private: + bool _value; +}; /** * Condition for a 'not' operator. @@ -529,6 +541,10 @@ readCondition( SGPropertyNode *prop_root, const SGPropertyNode *node ) false); else if (name == "not-equals") return readComparison(prop_root, node, SGComparisonCondition::EQUALS, true); + else if (name == "false") + return new SGConstantCondition(false); + else if (name == "true") + return new SGConstantCondition(true); else return 0; } -- 2.39.5