From: ThorstenB Date: Sun, 12 Jun 2011 18:32:13 +0000 (+0200) Subject: Introduce "PRESERVE" flag to protect properties on sim reset. X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=c782a32076016f2c3c01b4fd437b024dc77806e9;p=simgear.git Introduce "PRESERVE" flag to protect properties on sim reset. Some specific properties need protection and shouldn't be restored to their original values on sim-reset. --- diff --git a/simgear/props/props.hxx b/simgear/props/props.hxx index e870f440..60da557d 100644 --- a/simgear/props/props.hxx +++ b/simgear/props/props.hxx @@ -760,7 +760,8 @@ public: REMOVED = 8, TRACE_READ = 16, TRACE_WRITE = 32, - USERARCHIVE = 64 + USERARCHIVE = 64, + PRESERVE = 128 }; diff --git a/simgear/props/props_io.cxx b/simgear/props/props_io.cxx index e3ceaddb..9fea4497 100644 --- a/simgear/props/props_io.cxx +++ b/simgear/props/props_io.cxx @@ -227,6 +227,9 @@ PropsVisitor::startElement (const char * name, const XMLAttributes &atts) attval = atts.getValue("userarchive"); if (checkFlag(attval, false)) mode |= SGPropertyNode::USERARCHIVE; + attval = atts.getValue("preserve"); + if (checkFlag(attval, false)) + mode |= SGPropertyNode::PRESERVE; // Check for an alias. attval = atts.getValue("alias"); @@ -691,8 +694,12 @@ copyProperties (const SGPropertyNode *in, SGPropertyNode *out, int nChildren = in->nChildren(); for (int i = 0; i < nChildren; i++) { const SGPropertyNode * in_child = in->getChild(i); - if (!in_child->hasValue() || - (in_child->getAttributes() & attr_mask) == attr_value) + int mask = attr_mask; + /* attributes have no meaning for nodes without values - except + * the PRESERVE flag. So ignore them. */ + if (!in_child->hasValue()) + mask &= SGPropertyNode::PRESERVE; + if ((in_child->getAttributes() & mask) == (attr_value & mask)) { SGPropertyNode * out_child = out->getChild(in_child->getNameString(), in_child->getIndex(), @@ -704,9 +711,13 @@ copyProperties (const SGPropertyNode *in, SGPropertyNode *out, true); } else - if (out_child->hasValue() && - (out_child->getAttributes() & attr_mask) != attr_value) - out_child = NULL; + { + mask = attr_mask; + if (!out_child->hasValue()) + mask &= SGPropertyNode::PRESERVE; + if ((out_child->getAttributes() & mask) != (attr_value & mask)) + out_child = NULL; + } if (out_child && (!copyProperties(in_child, out_child, attr_value, attr_mask))) retval = false; diff --git a/simgear/scene/tsync/terrasync.cxx b/simgear/scene/tsync/terrasync.cxx index e2d28860..939ff6fb 100644 --- a/simgear/scene/tsync/terrasync.cxx +++ b/simgear/scene/tsync/terrasync.cxx @@ -627,6 +627,7 @@ void SGTerraSync::bind() // stalled is used as a signal handler (to connect listeners triggering GUI pop-ups) _stalled_node = _terraRoot->getNode("stalled", true); _stalled_node->setBoolValue(_svnThread->_stalled); + _stalled_node->setAttribute(SGPropertyNode::PRESERVE,true); } void SGTerraSync::unbind()