]> git.mxchange.org Git - flightgear.git/blobdiff - src/AIModel/AIScenario.cxx
Make the scenerio's work again (now for real) and a small number of updates.
[flightgear.git] / src / AIModel / AIScenario.cxx
index 4ad91d66b183e3fd46394a81d3bf773e536d6d23..cd46c170c8c6fd872b594fb81e1f5f2864f80c4a 100644 (file)
@@ -1,4 +1,4 @@
-// FGAIScenario - class for loading an AI scenario
+// FGAIScenario.cxx - class for loading an AI scenario
 // Written by David Culp, started May 2004
 // - davidculp2@comcast.net
 //
 #include <Main/fg_props.hxx>
 
 #include "AIScenario.hxx"
+#include "AIFlightPlan.hxx"
 
 
 
-FGAIScenario::FGAIScenario(string filename)
+FGAIScenario::FGAIScenario(string &filename)
 {
   int i;
   SGPath path( globals->get_fg_root() );
@@ -49,12 +50,13 @@ FGAIScenario::FGAIScenario(string filename)
       return;
   }
 
+  entries.clear();
   SGPropertyNode * node = root.getNode("scenario");
   for (i = 0; i < node->nChildren(); i++) { 
      //cout << "Reading entry " << i << endl;        
-     FGAIModelEntity* en = new FGAIModelEntity;
-     entries.push_back( en );
      SGPropertyNode * entry_node = node->getChild(i);
+
+     FGAIModelEntity* en = new FGAIModelEntity;
      en->callsign       = entry_node->getStringValue("callsign", "none");
      en->m_type         = entry_node->getStringValue("type", "aircraft");
      en->m_class        = entry_node->getStringValue("class", "jet_transport");
@@ -74,10 +76,18 @@ FGAIScenario::FGAIScenario(string filename)
      en->diameter       = entry_node->getDoubleValue("diameter-ft", 0.0);
      en->eda            = entry_node->getDoubleValue("eda", 0.007);
      en->life           = entry_node->getDoubleValue("life", 900.0);
-        en->buoyancy       = entry_node->getDoubleValue("buoyancy", 0);
-        en->wind_from_east = entry_node->getDoubleValue("wind_from_east", 0);
-        en->wind_from_north = entry_node->getDoubleValue("wind_from_north", 0);
-        en->wind            = entry_node->getBoolValue("wind", false);
+     en->buoyancy       = entry_node->getDoubleValue("buoyancy", 0);
+     en->wind_from_east = entry_node->getDoubleValue("wind_from_east", 0);
+     en->wind_from_north = entry_node->getDoubleValue("wind_from_north", 0);
+     en->wind            = entry_node->getBoolValue("wind", false);
+     en->cd              = entry_node->getDoubleValue  ("cd", 0.029); 
+     en->weight          = entry_node->getDoubleValue  ("weight", 0.030); 
+
+     en->fp             = NULL;
+     if (en->flightplan != ""){
+        en->fp = new FGAIFlightPlan( en->flightplan );
+     }
+     entries.push_back( en );
    }
 
   entry_iterator = entries.begin();
@@ -107,4 +117,4 @@ int FGAIScenario::nEntries( void )
   return entries.size();
 }
 
-
+// end scenario.cxx