- // 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,
- "Some errors restoring initial state (read-only props?)" );
+
+ for (int i=0; i<nd->nChildren(); ++i) {
+ SGPropertyNode* cp = nd->getChild(i);
+ treeClearAliases(cp);
+ }
+}
+
+void
+FGGlobals::resetPropertyRoot()
+{
+ delete locale;
+
+ cleanupListeners();
+
+ // we don't strictly need to clear these (they will be reset when we
+ // initProperties again), but trying to reduce false-positives when dumping
+ // ref-counts.
+ positionLon.clear();
+ positionLat.clear();
+ positionAlt.clear();
+ viewLon.clear();
+ viewLat.clear();
+ viewAlt.clear();
+ orientPitch.clear();
+ orientHeading.clear();
+ orientRoll.clear();
+
+ // clear aliases so ref-counts are accurate when dumped
+ treeClearAliases(props);
+
+ SG_LOG(SG_GENERAL, SG_INFO, "root props refcount:" << props.getNumRefs());
+ treeDumpRefCounts(0, props);
+
+ //BaseStackSnapshot::dumpAll(std::cout);
+
+ props = new SGPropertyNode;
+ initProperties();
+ locale = new FGLocale(props);
+
+ // remove /sim/fg-root before writing to prevent hijacking
+ SGPropertyNode *n = props->getNode("/sim", true);
+ n->removeChild("fg-root", 0);
+ n = n->getChild("fg-root", 0, true);
+ n->setStringValue(fg_root.c_str());
+ n->setAttribute(SGPropertyNode::WRITE, false);
+}
+
+static std::string autosaveName()
+{
+ std::ostringstream os;
+ string_list versionParts = simgear::strutils::split(VERSION, ".");
+ if (versionParts.size() < 2) {
+ return "autosave.xml";