]> git.mxchange.org Git - flightgear.git/blobdiff - src/AIModel/AIManager.cxx
Clear chat messages when an aircraft becomes inactive in the property tree.
[flightgear.git] / src / AIModel / AIManager.cxx
index effbf63b6f8c48070d599e78c10fa92319a39a0f..e0ef64813fa975a3f98bce4c99d4f486184faee3 100644 (file)
@@ -32,6 +32,7 @@
 #include "AICarrier.hxx"
 #include "AIStatic.hxx"
 #include "AIMultiplayer.hxx"
+#include "AITanker.hxx"
 
 #include <simgear/math/sg_geodesy.hxx>
 
@@ -78,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;
     }
 }
 
@@ -143,6 +155,8 @@ FGAIManager::update(double dt) {
             props->setIntValue("id", -1);
             props->setBoolValue("radar/in-range", false);
             props->setIntValue("refuel/tanker", false);
+            props->setStringValue("sim/multiplay/chat", "");
+            props->setStringValue("sim/multiplay/transmission-freq-hz", "");
 
             ai_list_itr = ai_list.erase(ai_list_itr);
         } else {
@@ -262,7 +276,11 @@ FGAIManager::processScenario( const string &filename ) {
             continue;
         std::string type = scEntry->getStringValue("type", "aircraft");
 
-        if (type == "aircraft") {
+         if (type == "tanker") { // refueling scenarios
+           FGAITanker* tanker = new FGAITanker;
+            tanker->readFromScenario(scEntry);
+            attach(tanker);
+    } else if (type == "aircraft") {
             FGAIAircraft* aircraft = new FGAIAircraft;
             aircraft->readFromScenario(scEntry);
             attach(aircraft);