]> git.mxchange.org Git - flightgear.git/commitdiff
David Culp:
authorehofman <ehofman>
Mon, 17 May 2004 08:45:33 +0000 (08:45 +0000)
committerehofman <ehofman>
Mon, 17 May 2004 08:45:33 +0000 (08:45 +0000)
First, preferences.xml will define the scenario filename.

For now, the other way of defining ai objects still works, so the sailboat
stays in preferences.xml.  Later, I'll move the sailboat into the demo
scenario.  If no scenario filename is given, then no scenario will be
processed.

I changed the demo scenario to create two 737's, one takes off on runway 01L,
and the other takes off on runway 01R.  This will make a good demo for the ai
system.  One problem, if you takeoff on 28L/R right away, you might run into
the taking-off 737's, or be scared.

src/AIModel/AIManager.cxx
src/AIModel/AIManager.hxx
src/AIModel/AIScenario.cxx
src/AIModel/AIScenario.hxx

index 9e5e7fb3c9641d0f41415c90106f0443adc47984..b4019554b31d7bdd679b6a6f6a1e6a1dee0ec5c9 100644 (file)
@@ -39,6 +39,7 @@ FGAIManager::FGAIManager() {
   numObjects = 0;
   _dt = 0.0;
   dt_count = 9;
+  scenario_filename = "";
 }
 
 FGAIManager::~FGAIManager() {
@@ -60,6 +61,10 @@ void FGAIManager::init() {
   for (int i = 0; i < root->nChildren(); i++) {
     const SGPropertyNode * entry = root->getChild(i);
 
+    if (!strcmp(entry->getName(), "scenario")){
+      scenario_filename = entry->getStringValue();
+    }
+
     if (!strcmp(entry->getName(), "entry")) {
       if (!strcmp(entry->getStringValue("type", ""), "aircraft")) { 
 
@@ -113,10 +118,7 @@ void FGAIManager::init() {
     }
   }
 
-  //**********  Flight Plan test code !!!! ****************
-  processScenario( "default_scenario" );
-  //******************************************************* 
-
+  if (scenario_filename != "") processScenario( scenario_filename );
   initDone = true;
 }
 
@@ -373,10 +375,12 @@ void FGAIManager::processThermal( FGAIThermal* thermal ) {
 void FGAIManager::processScenario( string filename ) {
   //cout << "AIManager: creating a scenario." << endl;
   FGAIScenario* s = new FGAIScenario( filename );
-  FGAIScenario::entry* en = s->getNextEntry();
-  if (en) {
-    FGAIFlightPlan* f = new FGAIFlightPlan( en->flightplan );
-    createAircraft("jet_transport", "Aircraft/737/Models/boeing733.xml", f);
+  for (int i=0;i<s->nEntries();i++) {
+    FGAIScenario::entry* en = s->getNextEntry();
+    if (en) {
+      FGAIFlightPlan* f = new FGAIFlightPlan( en->flightplan );
+      createAircraft("jet_transport", "Aircraft/737/Models/boeing733.xml", f);
+    }
   }
   delete s;
 }
index 106d0abb33cf9703e3d38682a19c5830307b5cc6..b6cdd8a9c679f8e82f5632cf195bc50f46c93c25 100644 (file)
@@ -128,6 +128,7 @@ private:
     int numObjects;
     SGPropertyNode* root;
     SGPropertyNode* wind_from_down;
+    string scenario_filename;
 
     double user_latitude;
     double user_longitude;
index 8cd66f3164f63f18193486d9e62297fa203f9a6f..07013c9aff59e30a9acf2af23f374cc4cd7465ee 100644 (file)
@@ -53,9 +53,11 @@ FGAIScenario::FGAIScenario(string filename)
      entries.push_back( en );
      SGPropertyNode * entry_node = node->getChild(i);
      en->callsign       = entry_node->getStringValue("callsign", "none");
+     en->aitype         = entry_node->getStringValue("type", "aircraft");
      en->aircraft_class = entry_node->getStringValue("class", "jet_transport");
      en->model_path     = entry_node->getStringValue("model", "Models/Geometry/glider.ac");
      en->flightplan     = entry_node->getStringValue("flightplan", "");
+     en->repeat         = entry_node->getDoubleValue("repeat", 0.0); 
    }
 
   entry_iterator = entries.begin();
@@ -72,7 +74,12 @@ FGAIScenario::~FGAIScenario()
 FGAIScenario::entry*
 FGAIScenario::getNextEntry( void )
 {
-  return *entry_iterator;
+  if (entries.size() == 0) return 0;
+  if (entry_iterator != entries.end()) {
+    return *entry_iterator++;
+  } else {
+    return 0;
+  }
 }
 
 int FGAIScenario::nEntries( void )
index 2e35d91b7b21a2d50f04dc59ae7f5e629b51f82e..949c72768e3a3a92133091f83fc6906cff342ea0 100644 (file)
@@ -32,9 +32,11 @@ public:
 
   typedef struct {
    string callsign;
+   string aitype;       // can be aircraft, ship, storm, thermal
    string aircraft_class;
    string model_path;
    string flightplan;
+   double repeat;       // in seconds
   } entry;
 
    FGAIScenario(string filename);