]> git.mxchange.org Git - flightgear.git/commitdiff
let the --prop: option overwrite write-protected properties
authormfranz <mfranz>
Wed, 9 Jul 2008 15:09:23 +0000 (15:09 +0000)
committermfranz <mfranz>
Wed, 9 Jul 2008 15:09:23 +0000 (15:09 +0000)
("The user is always right, but not always bright.")

src/Main/options.cxx

index af14284af81ab996840b2fd00123ab4059215215..37ba8f6fa242fbc1cfe2e8119480201038f2a139 100644 (file)
@@ -1443,22 +1443,29 @@ set_property(const string& arg)
     }
     SGPropertyNode *n = fgGetNode(name.c_str(), true);
 
+    bool writable = n->getAttribute(SGPropertyNode::WRITE);
+    if (!writable)
+        n->setAttribute(SGPropertyNode::WRITE, true);
+
+    bool ret = false;
     if (type.empty())
-        return n->setUnspecifiedValue(value.c_str());
+        ret = n->setUnspecifiedValue(value.c_str());
     else if (type == "s" || type == "string")
-        return n->setStringValue(value.c_str());
+        ret = n->setStringValue(value.c_str());
     else if (type == "d" || type == "double")
-        return n->setDoubleValue(strtod(value.c_str(), 0));
+        ret = n->setDoubleValue(strtod(value.c_str(), 0));
     else if (type == "f" || type == "float")
-        return n->setFloatValue(atof(value.c_str()));
+        ret = n->setFloatValue(atof(value.c_str()));
     else if (type == "l" || type == "long")
-        return n->setLongValue(strtol(value.c_str(), 0, 0));
+        ret =  n->setLongValue(strtol(value.c_str(), 0, 0));
     else if (type == "i" || type == "int")
-        return n->setIntValue(atoi(value.c_str()));
+        ret =  n->setIntValue(atoi(value.c_str()));
     else if (type == "b" || type == "bool")
-        return n->setBoolValue(value == "true" || atoi(value.c_str()) != 0);
+        ret =  n->setBoolValue(value == "true" || atoi(value.c_str()) != 0);
 
-    return false;
+    if (!writable)
+        n->setAttribute(SGPropertyNode::WRITE, false);
+    return ret;
 }