]> git.mxchange.org Git - flightgear.git/commitdiff
Tweaks for run-time scenario toggling.
authorJames Turner <zakalawe@mac.com>
Tue, 2 Apr 2013 17:00:31 +0000 (18:00 +0100)
committerJames Turner <zakalawe@mac.com>
Tue, 2 Apr 2013 17:00:31 +0000 (18:00 +0100)
src/AIModel/AIManager.cxx

index f2af74acb2a77ded98e56c999719a95a9b531338..8652641f9ff445cbf220f91f06b416ee6f7d2b21 100644 (file)
@@ -303,6 +303,16 @@ FGAIManager::processThermal( double dt, FGAIThermal* thermal ) {
 bool FGAIManager::loadScenarioCommand(const SGPropertyNode* args)
 {
     std::string name = args->getStringValue("name");
+    if (args->hasChild("load-property")) {
+        // slightly ugly, to simplify life in the dialogs, make load allow
+        // loading or unloading based on a bool property.
+        bool loadIt = fgGetBool(args->getStringValue("load-property"));
+        if (!loadIt) {
+            // user actually wants to unload, fine.
+            return unloadScenario(name);
+        }
+    }
+    
     if (_scenarios.find(name) != _scenarios.end()) {
         SG_LOG(SG_AI, SG_WARN, "scenario '" << name << "' already loaded");
         return false;
@@ -315,6 +325,7 @@ bool FGAIManager::loadScenarioCommand(const SGPropertyNode* args)
         for (; root->hasChild("scenario", index); ++index) {}
         
         SGPropertyNode* scenarioNode = root->getChild("scenario", index, true);
+        scenarioNode->setAttribute(SGPropertyNode::USERARCHIVE, true);
         scenarioNode->setStringValue(name);
     }