]> git.mxchange.org Git - flightgear.git/blobdiff - src/AIModel/AIManager.cxx
backport from JSBSim/cvs: apply prop sense only once (OK'ed by JSB)
[flightgear.git] / src / AIModel / AIManager.cxx
index 6d9a3cf5ac7f1771cc73d5a461422ab699271255..cec1980acae042af721f65470b2b95bcdcf2d148 100644 (file)
@@ -79,13 +79,24 @@ FGAIManager::init() {
 void
 FGAIManager::postinit() {
     // postinit, so that it can access the Nasal subsystem
-    for(int i = 0 ; i < root->nChildren() ; i++) {
-        SGPropertyNode *aiEntry = root->getChild( i );
-        if( !strcmp( aiEntry->getName(), "scenario" ) ) {
-            scenario_filename = aiEntry->getStringValue();
-            if (!scenario_filename.empty())
-                processScenario( scenario_filename );
+    map<string, bool> scenarios;
+    for (int i = 0 ; i < root->nChildren() ; i++) {
+        SGPropertyNode *n = root->getChild(i);
+        if (strcmp(n->getName(), "scenario"))
+            continue;
+
+        string name = n->getStringValue();
+        if (name.empty())
+            continue;
+
+        if (scenarios.find(name) != scenarios.end()) {
+            SG_LOG(SG_GENERAL, SG_WARN, "won't load scenario '" << name << "' twice");
+            continue;
         }
+
+        SG_LOG(SG_GENERAL, SG_INFO, "loading scenario '" << name << '\'');
+        processScenario(name);
+        scenarios[name] = true;
     }
 }
 
@@ -264,9 +275,9 @@ FGAIManager::processScenario( const string &filename ) {
         std::string type = scEntry->getStringValue("type", "aircraft");
 
          if (type == "tanker") { // refueling scenarios
-           FGAITanker* aircraft = new FGAITanker;
-            aircraft->readFromScenario(scEntry);
-            attach(aircraft);        
+           FGAITanker* tanker = new FGAITanker;
+            tanker->readFromScenario(scEntry);
+            attach(tanker);
     } else if (type == "aircraft") {
             FGAIAircraft* aircraft = new FGAIAircraft;
             aircraft->readFromScenario(scEntry);