]> git.mxchange.org Git - flightgear.git/commitdiff
prevent multiple loading of one and the same scenario
authormfranz <mfranz>
Fri, 3 Aug 2007 18:02:33 +0000 (18:02 +0000)
committermfranz <mfranz>
Fri, 3 Aug 2007 18:02:33 +0000 (18:02 +0000)
src/AIModel/AIManager.cxx
src/AIModel/AIManager.hxx

index 19a6c76b1f9ecb4d85817dea778a663b64423d81..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;
     }
 }
 
index a327421ef365082f88f636746c52397d3c410587..2bcd4a541b25248251540c3fc54cf3f7e7e57d74 100644 (file)
@@ -110,8 +110,6 @@ private:
     SGPropertyNode_ptr wind_from_east_node;
     SGPropertyNode_ptr wind_from_north_node;
 
-    string scenario_filename;
-
     double user_latitude;
     double user_longitude;
     double user_altitude;