{
initial_state = new SGPropertyNode();
- // copy properties which are READ/WRITEable - but not USERARCHIVEd
- if (!copyProperties(props, initial_state,
- SGPropertyNode::READ+SGPropertyNode::WRITE,
- SGPropertyNode::READ+SGPropertyNode::WRITE+SGPropertyNode::USERARCHIVE))
+ // copy properties which are READ/WRITEable - but not USERARCHIVEd or PRESERVEd
+ int checked = SGPropertyNode::READ+SGPropertyNode::WRITE+
+ SGPropertyNode::USERARCHIVE+SGPropertyNode::PRESERVE;
+ int expected = SGPropertyNode::READ+SGPropertyNode::WRITE;
+ if (!copyProperties(props, initial_state, expected, checked))
SG_LOG(SG_GENERAL, SG_ALERT, "Error saving initial state");
// delete various properties from the initial state, since we want to
// preserve their values even if doing a restore
-
+ // => Properties should now use the PRESERVE flag to protect their values
+ // on sim-reset. Remove some specific properties for backward compatibility.
SGPropertyNode* sim = initial_state->getChild("sim");
- sim->removeChild("presets");
- SGPropertyNode* simStartup = sim->getChild("startup");
- simStartup->removeChild("xsize");
- simStartup->removeChild("ysize");
-
SGPropertyNode* cameraGroupNode = sim->getNode("rendering/camera-group");
if (cameraGroupNode) {
cameraGroupNode->removeChild("camera");
"No initial state available to restore!!!");
return;
}
- // restore properties which are READ/WRITEable - but not USERARCHIVEd
- if ( copyProperties(initial_state, props,
- SGPropertyNode::READ+SGPropertyNode::WRITE,
- SGPropertyNode::READ+SGPropertyNode::WRITE+SGPropertyNode::USERARCHIVE)) {
+ // copy properties which are READ/WRITEable - but not USERARCHIVEd or PRESERVEd
+ int checked = SGPropertyNode::READ+SGPropertyNode::WRITE+
+ SGPropertyNode::USERARCHIVE+SGPropertyNode::PRESERVE;
+ int expected = SGPropertyNode::READ+SGPropertyNode::WRITE;
+ if ( copyProperties(initial_state, props, expected, checked)) {
SG_LOG( SG_GENERAL, SG_INFO, "Initial state restored successfully" );
} else {
SG_LOG( SG_GENERAL, SG_INFO,
enable->addChangeListener(listener, false);
}
}
- n->setBoolValue("loaded",is_loaded);
+ SGPropertyNode* loaded = n->getChild("loaded",0,true);
+ loaded->setAttribute(SGPropertyNode::PRESERVE,true);
+ loaded->setBoolValue(is_loaded);
}
// Logs a runtime error, with stack trace, to the FlightGear log stream
else if(!strcmp(a, "trace-read")) attr = SGPropertyNode::TRACE_READ;
else if(!strcmp(a, "trace-write")) attr = SGPropertyNode::TRACE_WRITE;
else if(!strcmp(a, "userarchive")) attr = SGPropertyNode::USERARCHIVE;
+ else if(!strcmp(a, "preserve")) attr = SGPropertyNode::PRESERVE;
else {
naRuntimeError(c, "props.getAttribute() with invalid attribute");
return naNil();
else if(!strcmp(a, "trace-read")) attr = SGPropertyNode::TRACE_READ;
else if(!strcmp(a, "trace-write")) attr = SGPropertyNode::TRACE_WRITE;
else if(!strcmp(a, "userarchive")) attr = SGPropertyNode::USERARCHIVE;
+ else if(!strcmp(a, "preserve")) attr = SGPropertyNode::PRESERVE;
else {
naRuntimeError(c, "props.setAttribute() with invalid attribute");
return naNil();