]> git.mxchange.org Git - flightgear.git/commitdiff
Make use of a pointer to a structure to pass multiple parameters around.
authorehofman <ehofman>
Tue, 7 Sep 2004 09:53:23 +0000 (09:53 +0000)
committerehofman <ehofman>
Tue, 7 Sep 2004 09:53:23 +0000 (09:53 +0000)
12 files changed:
src/AIModel/AIBase.cxx
src/AIModel/AIBase.hxx
src/AIModel/AIFlightPlan.cxx
src/AIModel/AIFlightPlan.hxx
src/AIModel/AIManager.cxx
src/AIModel/AIManager.hxx
src/AIModel/AIScenario.cxx
src/AIModel/AIScenario.hxx
src/Systems/submodel.cxx
src/Systems/submodel.hxx
src/Traffic/Schedule.cxx
src/Traffic/TrafficMgr.cxx

index a91f8d0a9ade3ffaba4d92eddfca41ee49d44726..e69602253bc19755fbc01d34d58fcf68c1661410 100644 (file)
@@ -57,6 +57,8 @@ FGAIBase::FGAIBase() {
     _otype = otNull;
     index = 0;
     fp = (FGAIFlightPlan*)0;
+    delete_me = false;
+    manager = NULL;
 }
 
 FGAIBase::~FGAIBase() {
@@ -89,8 +91,10 @@ void FGAIBase::Transform() {
 bool FGAIBase::init() {
 
    SGPropertyNode *root = globals->get_props()->getNode("ai/models", true);
+
    index = manager->getNum(_otype) - 1;
    props = root->getNode(_type_str.c_str(), index, true);
+
    if (model_path != "") {
       model = sgLoad3DModel( globals->get_fg_root(),
                             model_path.c_str(),
index a46e945265387729dfe95d758b259e169e13cdd3..51ad35db511714d6704ec823e7167c68ef5ff6ca 100644 (file)
 #include <simgear/scene/model/placement.hxx>
 
 #include <Main/fg_props.hxx>
-#include "AIFlightPlan.hxx"
 
 SG_USING_STD(string);
 
 class FGAIManager;
+class FGAIFlightPlan;
+
+
+typedef struct {
+   string callsign;
+
+   // can be aircraft, ship, storm, thermal or ballistic
+   const char* m_type;
+   const char* m_class;
+   const char* path;
+   const char* flightplan;
+
+   FGAIFlightPlan *fp;
+
+   double repeat;             // in seconds
+   double latitude;           // used if no flightplan defined
+   double longitude;          // used if no flightplan defined
+   double altitude;           // used if no flightplan defined
+   double speed;              // used if no flightplan defined
+   double heading;            // used if no flightplan defined
+   double roll;               // used if no flightplan defined
+   double azimuth;            // used by ballistic objects
+   double elevation;          // used by ballistic objects
+   double rudder;             // used by ship objects
+   double strength;           // used by thermal objects
+   double diameter;           // used by thermal objects
+   double eda;                // used by ballistic objects
+   double life;               // life span in seconds
+   double buoyancy;           // acceleration in ft per sec2
+   double wind_from_east;     // in feet per second
+   double wind_from_north;    // in feet per second
+   bool wind;
+} FGAIModelEntity;
+
 
 class FGAIBase {
 
index 2c838f8248c5f11ea86e53941dea4836f06b3a96..04bfbe357592aaf9910b2992b2438b8efaf4308b 100644 (file)
@@ -89,11 +89,7 @@ FGAIFlightPlan::FGAIFlightPlan(string filename)
 // Position computed by the traffic manager, as well
 // as setting speeds and altitude computed by the
 // traffic manager. 
-FGAIFlightPlan::FGAIFlightPlan(string filename, 
-                              double lat, 
-                              double lon,
-                              double alt,
-                              double speed,
+FGAIFlightPlan::FGAIFlightPlan(FGAIModelEntity *entity,
                               double course, 
                               FGAirport *dep,
                               FGAirport *arr)
@@ -101,7 +97,8 @@ FGAIFlightPlan::FGAIFlightPlan(string filename,
   bool useInitialWayPoint = true;
   bool useCurrentWayPoint = false;
   SGPath path( globals->get_fg_root() );
-  path.append( ("/Data/AI/FlightPlans/" + filename).c_str() );
+  path.append( "/Data/AI/FlightPlans" );
+  path.append( entity->path );
   SGPropertyNode root;
 
   try {
@@ -135,17 +132,17 @@ FGAIFlightPlan::FGAIFlightPlan(string filename,
     // cout << path.str() << endl;
     // cout << "Trying to create this plan dynamically" << endl;
     // cout << "Route from " << dep->id << " to " << arr->id << endl;
-       create(dep,arr, alt, speed);
+       create(dep,arr, entity->altitude, entity->speed);
        // Now that we have dynamically created a flight plan,
        // we need to add some code that pops any waypoints already past.
        //return;
   }
   waypoint* init_waypoint   = new waypoint;
   init_waypoint->name       = string("initial position");
-  init_waypoint->latitude   = lat;
-  init_waypoint->longitude  = lon;
-  init_waypoint->altitude   = alt;
-  init_waypoint->speed      = speed;
+  init_waypoint->latitude   = entity->latitude;
+  init_waypoint->longitude  = entity->longitude;
+  init_waypoint->altitude   = entity->altitude;
+  init_waypoint->speed      = entity->speed;
   init_waypoint->crossat    = - 10000;
   init_waypoint->gear_down  = false;
   init_waypoint->flaps_down = false;
index 4aebc90b072de4d70d9f26a7975ecf99417cfe66..8cc6bb888238c9faba99e32146e2d041217a5619 100644 (file)
@@ -25,6 +25,8 @@
 
 #include <Airports/simple.hxx>
 
+#include "AIBase.hxx"
+
 SG_USING_STD(vector);
 SG_USING_STD(string);
 
@@ -47,11 +49,7 @@ public:
   } waypoint;
 
    FGAIFlightPlan(string filename);
-  FGAIFlightPlan(string filename, 
-                double lat, 
-                double lon,
-                double alt, 
-                double speed, 
+  FGAIFlightPlan(FGAIModelEntity *entity,
                 double course,
                 FGAirport *dep,
                 FGAirport *arr);
index b81167a66725069b3406d78e6fca8f7a0e435f9e..3cc50714ab6e3892b9981b95259e0bcfb8739f1d 100644 (file)
@@ -1,5 +1,5 @@
 // AIManager.cxx  Based on David Luff's AIMgr:
-// - a global management class for AI objects
+// - a global management type for AI objects
 //
 // Written by David Culp, started October 2003.
 // - davidculp2@comcast.net
@@ -40,6 +40,8 @@ FGAIManager::FGAIManager() {
   _dt = 0.0;
   dt_count = 9;
   scenario_filename = "";
+  ai_list.clear();
+  ids.clear();
 }
 
 FGAIManager::~FGAIManager() {
@@ -60,7 +62,7 @@ void FGAIManager::init() {
   if (!enabled)
       return;
 
-  wind_from_down = fgGetNode("/environment/wind-from-down-fps", true);
+  wind_from_down_node = fgGetNode("/environment/wind-from-down-fps", true);
  
   scenario_filename = root->getNode("scenario", true)->getStringValue();
 
@@ -114,7 +116,7 @@ void FGAIManager::update(double dt) {
                 }
                 ++ai_list_itr;
         }
-        wind_from_down->setDoubleValue( strength );
+        wind_from_down_node->setDoubleValue( strength );
 
 }
 
@@ -153,160 +155,117 @@ void FGAIManager::freeID( int ID ) {
     }  
 }
 
-int FGAIManager::createAircraft( string model_class, string path,
-              double latitude, double longitude, double altitude,
-              double heading, double speed, double roll ) {
+int FGAIManager::createAircraft( FGAIModelEntity *entity ) {
      
         FGAIAircraft* ai_plane = new FGAIAircraft(this);
         ai_list.push_back(ai_plane);
         ai_plane->setID( assignID() );
         ++numObjects;
-        if (model_class == "light") {
+        if (entity->m_class == "light") {
           ai_plane->SetPerformance(&FGAIAircraft::settings[FGAIAircraft::LIGHT]);
-        } else if (model_class == "ww2_fighter") {
+        } else if (entity->m_class == "ww2_fighter") {
           ai_plane->SetPerformance(&FGAIAircraft::settings[FGAIAircraft::WW2_FIGHTER]);
-        } else if (model_class ==  "jet_transport") {
+        } else if (entity->m_class ==  "jet_transport") {
           ai_plane->SetPerformance(&FGAIAircraft::settings[FGAIAircraft::JET_TRANSPORT]);
-        } else if (model_class == "jet_fighter") {
+        } else if (entity->m_class == "jet_fighter") {
           ai_plane->SetPerformance(&FGAIAircraft::settings[FGAIAircraft::JET_FIGHTER]);
-        } else if (model_class ==  "tanker") {
+        } else if (entity->m_class ==  "tanker") {
           ai_plane->SetPerformance(&FGAIAircraft::settings[FGAIAircraft::JET_TRANSPORT]);
           ai_plane->SetTanker(true);
         } else {
           ai_plane->SetPerformance(&FGAIAircraft::settings[FGAIAircraft::JET_TRANSPORT]);
         }
-        ai_plane->setHeading(heading);
-        ai_plane->setSpeed(speed);
-        ai_plane->setPath(path.c_str());
-        ai_plane->setAltitude(altitude);
-        ai_plane->setLongitude(longitude);
-        ai_plane->setLatitude(latitude);
-        ai_plane->setBank(roll);
-        ai_plane->init();
-        ai_plane->bind();
-        return ai_plane->getID();
-}
-
-
-int FGAIManager::createAircraft( string model_class, string path,
-              FGAIFlightPlan* flightplan ) {
-     
-        FGAIAircraft* ai_plane = new FGAIAircraft(this);
-        ai_list.push_back(ai_plane);
-        ai_plane->setID( assignID() );
-        ++numObjects;
-        if (model_class == "light") {
-          ai_plane->SetPerformance(&FGAIAircraft::settings[FGAIAircraft::LIGHT]);
-        } else if (model_class == "ww2_fighter") {
-          ai_plane->SetPerformance(&FGAIAircraft::settings[FGAIAircraft::WW2_FIGHTER]);
-        } else if (model_class ==  "jet_transport") {
-          ai_plane->SetPerformance(&FGAIAircraft::settings[FGAIAircraft::JET_TRANSPORT]);
-        } else if (model_class == "jet_fighter") {
-          ai_plane->SetPerformance(&FGAIAircraft::settings[FGAIAircraft::JET_FIGHTER]);
-        } else if (model_class ==  "tanker") {
-          ai_plane->SetPerformance(&FGAIAircraft::settings[FGAIAircraft::JET_TRANSPORT]);
-          ai_plane->SetTanker(true);
-        } else {
-          ai_plane->SetPerformance(&FGAIAircraft::settings[FGAIAircraft::JET_TRANSPORT]);
+        ai_plane->setHeading(entity->heading);
+        ai_plane->setSpeed(entity->speed);
+        ai_plane->setPath(entity->path);
+        ai_plane->setAltitude(entity->altitude);
+        ai_plane->setLongitude(entity->longitude);
+        ai_plane->setLatitude(entity->latitude);
+        ai_plane->setBank(entity->roll);
+
+        if ( entity->fp ) {
+          ai_plane->SetFlightPlan(entity->fp);
         }
-        ai_plane->setPath(path.c_str());
-        ai_plane->SetFlightPlan(flightplan);
+
         ai_plane->init();
         ai_plane->bind();
         return ai_plane->getID();
 }
 
-
-int FGAIManager::createShip( string path, double latitude, double longitude,
-                             double altitude, double heading, double speed,
-                             double rudder ) {
+int FGAIManager::createShip( FGAIModelEntity *entity ) {
 
         FGAIShip* ai_ship = new FGAIShip(this);
         ai_list.push_back(ai_ship);
         ai_ship->setID( assignID() );
         ++numObjects;
-        ai_ship->setHeading(heading);
-        ai_ship->setSpeed(speed);
-        ai_ship->setPath(path.c_str());
-        ai_ship->setAltitude(altitude);
-        ai_ship->setLongitude(longitude);
-        ai_ship->setLatitude(latitude);
-        ai_ship->setBank(rudder);
-        ai_ship->init();
-        ai_ship->bind();
-        return ai_ship->getID();
-}
-
-int FGAIManager::createShip( string path, FGAIFlightPlan* flightplan ) {
+        ai_ship->setHeading(entity->heading);
+        ai_ship->setSpeed(entity->speed);
+        ai_ship->setPath(entity->path);
+        ai_ship->setAltitude(entity->altitude);
+        ai_ship->setLongitude(entity->longitude);
+        ai_ship->setLatitude(entity->latitude);
+        ai_ship->setBank(entity->rudder);
+
+        if ( entity->fp ) {
+           ai_ship->setFlightPlan(entity->fp);
+        }
 
-        FGAIShip* ai_ship = new FGAIShip(this);
-        ai_list.push_back(ai_ship);
-        ai_ship->setID( assignID() );
-        ++numObjects;
-        ai_ship->setPath(path.c_str());
-        ai_ship->setFlightPlan(flightplan); 
         ai_ship->init();
         ai_ship->bind();
         return ai_ship->getID();
 }
 
-
-int FGAIManager::createBallistic( string path, double latitude, double longitude,
-                                  double altitude, double azimuth, double elevation,
-                                  double speed, double eda, double life, double buoyancy,
-                                                                 double wind_from_east, double wind_from_north, bool wind ) {
+int FGAIManager::createBallistic( FGAIModelEntity *entity ) {
 
         FGAIBallistic* ai_ballistic = new FGAIBallistic(this);
         ai_list.push_back(ai_ballistic);
         ai_ballistic->setID( assignID() );    
         ++numObjects;
-        ai_ballistic->setAzimuth(azimuth);
-        ai_ballistic->setElevation(elevation);
-        ai_ballistic->setSpeed(speed);
-        ai_ballistic->setPath(path.c_str());
-        ai_ballistic->setAltitude(altitude);
-        ai_ballistic->setLongitude(longitude);
-        ai_ballistic->setLatitude(latitude);
-        ai_ballistic->setDragArea(eda);
-        ai_ballistic->setLife(life);
-        ai_ballistic->setBuoyancy(buoyancy);
-               ai_ballistic->setWind_from_east(wind_from_east);
-               ai_ballistic->setWind_from_north(wind_from_north);
-               ai_ballistic->setWind(wind);
+        ai_ballistic->setAzimuth(entity->azimuth);
+        ai_ballistic->setElevation(entity->elevation);
+        ai_ballistic->setSpeed(entity->speed);
+        ai_ballistic->setPath(entity->path);
+        ai_ballistic->setAltitude(entity->altitude);
+        ai_ballistic->setLongitude(entity->longitude);
+        ai_ballistic->setLatitude(entity->latitude);
+        ai_ballistic->setDragArea(entity->eda);
+        ai_ballistic->setLife(entity->life);
+        ai_ballistic->setBuoyancy(entity->buoyancy);
+       ai_ballistic->setWind_from_east(entity->wind_from_east);
+       ai_ballistic->setWind_from_north(entity->wind_from_north);
+       ai_ballistic->setWind(entity->wind);
         ai_ballistic->init();
         ai_ballistic->bind();
         return ai_ballistic->getID();
 }
 
-int FGAIManager::createStorm( string path, double latitude, double longitude,
-                             double altitude, double heading, double speed ) {
+int FGAIManager::createStorm( FGAIModelEntity *entity ) {
 
         FGAIStorm* ai_storm = new FGAIStorm(this);
         ai_list.push_back(ai_storm);
         ai_storm->setID( assignID() );
         ++numObjects;
-        ai_storm->setHeading(heading);
-        ai_storm->setSpeed(speed);
-        ai_storm->setPath(path.c_str());
-        ai_storm->setAltitude(altitude);
-        ai_storm->setLongitude(longitude);
-        ai_storm->setLatitude(latitude);
+        ai_storm->setHeading(entity->heading);
+        ai_storm->setSpeed(entity->speed);
+        ai_storm->setPath(entity->path);
+        ai_storm->setAltitude(entity->altitude);
+        ai_storm->setLongitude(entity->longitude);
+        ai_storm->setLatitude(entity->latitude);
         ai_storm->init();
         ai_storm->bind();
         return ai_storm->getID();
 }
 
-int FGAIManager::createThermal( double latitude, double longitude,
-                                double strength, double diameter ) {
+int FGAIManager::createThermal( FGAIModelEntity *entity ) {
 
         FGAIThermal* ai_thermal = new FGAIThermal(this);
         ai_list.push_back(ai_thermal);
         ai_thermal->setID( assignID() );
         ++numObjects;
-        ai_thermal->setLongitude(longitude);
-        ai_thermal->setLatitude(latitude);
-        ai_thermal->setMaxStrength(strength);
-        ai_thermal->setDiameter(diameter / 6076.11549);
+        ai_thermal->setLongitude(entity->longitude);
+        ai_thermal->setLatitude(entity->latitude);
+        ai_thermal->setMaxStrength(entity->strength);
+        ai_thermal->setDiameter(entity->diameter / 6076.11549);
         ai_thermal->init();
         ai_thermal->bind();
         return ai_thermal->getID();
@@ -355,43 +314,30 @@ void FGAIManager::processThermal( FGAIThermal* thermal ) {
 
 void FGAIManager::processScenario( string filename ) {
   FGAIScenario* s = new FGAIScenario( filename );
-  FGAIFlightPlan* f;
 
   for (int i=0;i<s->nEntries();i++) {
-    FGAIScenario::entry* en = s->getNextEntry();
-    f = 0;
+    FGAIModelEntity* en = s->getNextEntry();
+
     if (en) {
+      en->fp = NULL;
       if (en->flightplan != ""){
-        f = new FGAIFlightPlan( en->flightplan );
-      }  
-      if (en->aitype == "aircraft"){
-         if (f){
-           createAircraft( en->aircraft_class, en->model_path, f );
-         } else {
-           createAircraft( en->aircraft_class, en->model_path, en->latitude,
-                           en->longitude, en->altitude, en->heading,
-                           en->speed, en->roll );
-         } 
-      } else if (en->aitype == "ship"){
-         if (f){
-           createShip( en->model_path, f );
-         } else {
-           createShip( en->model_path, en->latitude,
-                           en->longitude, en->altitude, en->heading,
-                           en->speed, en->rudder );
-         } 
-
-      } else if (en->aitype == "storm"){
-        createStorm( en->model_path, en->latitude, en->longitude,
-                     en->altitude, en->heading, en->speed ); 
-      } else if (en->aitype == "thermal"){
-        createThermal( en->latitude, en->longitude, en->strength, 
-                       en->diameter );
-      } else if (en->aitype == "ballistic"){
-        createBallistic( en->model_path, en->latitude, en->longitude,
-                         en->altitude, en->azimuth, en->elevation, en->speed,
-                         en->eda, en->life, en->buoyancy, en->wind_from_east,
-                                                en-> wind_from_north, en->wind);
+        en->fp = new FGAIFlightPlan( en->flightplan );
+      }
+      if (en->m_class == "aircraft") {
+         createAircraft( en );
+
+      } else if (en->m_class == "ship") {
+           createShip( en );
+
+      } else if (en->m_class == "storm") {
+        createStorm( en );
+
+      } else if (en->m_class == "thermal") {
+        createThermal( en );
+
+      } else if (en->m_class == "ballistic") {
+        createBallistic( en );
       }      
     }
   }
index 809efba1e9f56fdb37f6b8d48e9a8ddcb2115596..8433b7ab07864d521c464ae7f1efc9ea63cfb71a 100644 (file)
 #ifndef _FG_AIMANAGER_HXX
 #define _FG_AIMANAGER_HXX
 
+#include <list>
+
 #include <simgear/structure/subsystem_mgr.hxx>
+
 #include <Main/fg_props.hxx>
-#include <list>
-#include "AIBase.hxx"
-#include "AIScenario.hxx"
-#include "AIFlightPlan.hxx"
+
+#include <AIModel/AIBase.hxx>
+#include <AIModel/AIScenario.hxx>
+#include <AIModel/AIFlightPlan.hxx>
 
 SG_USING_STD(list);
 class FGAIThermal;
@@ -67,70 +70,12 @@ public:
     int assignID();
     void freeID(int ID);
 
-    int createAircraft( string model_class, // see FGAIAircraft.hxx for possible classes
-                        string path,        // path to exterior model
-                        double latitude,    // in degrees -90 to 90
-                        double longitude,   // in degrees -180 to 180
-                        double altitude,    // in feet
-                        double heading,     // true heading in degrees
-                        double speed,       // in knots true airspeed (KTAS)    
-                        double roll = 0 );  // in degrees
-
-    int createAircraft( string model_class, // see FGAIAircraft.hxx for possible classes
-                        string path,        // path to exterior model
-                        FGAIFlightPlan *flightplan );
-
-    int createShip(     string path,        // path to exterior model
-                        double latitude,    // in degrees -90 to 90
-                        double longitude,   // in degrees -180 to 180
-                        double altitude,    // in feet  (ex. for a lake!)
-                        double heading,     // true heading in degrees
-                        double speed,       // in knots true
-                        double rudder );    // in degrees (right is positive)(0 to 5 works best)
-
-    int createShip(     string path,        // path to exterior model
-                        FGAIFlightPlan *flightplan );
-
-    int createBallistic( string path,           // path to exterior model
-                         double latitude,       // in degrees -90 to 90
-                         double longitude,      // in degrees -180 to 180
-                         double altitude,       // in feet
-                         double azimuth,        // in degrees (same as heading)
-                         double elevation,      // in degrees (same as pitch)
-                         double speed,          // in feet per second
-                         double eda,            // equivalent drag area, ft2
-                         double life,           // life span in seconds
-                         double buoyancy,       // acceleration due to buoyancy feet per second2
-                         double wind_from_east, // in feet per second
-                                                double wind_from_north,  // in feet per second
-                                                bool wind               // val
-                                                );
-     
-    int createStorm( string path,        // path to exterior model
-                     double latitude,    // in degrees -90 to 90
-                     double longitude,   // in degrees -180 to 180
-                     double altitude,    // in feet
-                     double heading,     // true heading in degrees
-                     double speed );     // in knots true airspeed (KTAS)    
-
-    int createThermal( double latitude,    // in degrees -90 to 90
-                       double longitude,   // in degrees -180 to 180
-                       double strength,    // in feet per second
-                       double diameter );  // in feet
-
-    int createSmoke     ( string path,       // path to exterior model
-                         double latitude,   // in degrees -90 to 90
-                         double longitude,  // in degrees -180 to 180
-                         double altitude,   // in feet
-                         double azimuth,    // in degrees (same as heading)
-                         double elevation,  // in degrees (same as pitch)
-                         double speed,      // in feet per second
-                         double eda,        // equivalent drag area, ft2
-                        double life,        // life span in seconds
-                        double buoyancy    // acceleration due to buoyancy feet per second2
-                         );
-
-                 
+    int createBallistic( FGAIModelEntity *entity );
+    int createAircraft( FGAIModelEntity *entity );
+    int createThermal( FGAIModelEntity *entity );
+    int createStorm( FGAIModelEntity *entity );
+    int createShip( FGAIModelEntity *entity );
+
     void destroyObject( int ID );
 
     inline double get_user_latitude() { return user_latitude; }
@@ -150,7 +95,7 @@ private:
     bool enabled;
     int numObjects;
     SGPropertyNode* root;
-    SGPropertyNode* wind_from_down;
+    SGPropertyNode* wind_from_down_node;
     string scenario_filename;
 
     double user_latitude;
index af9c525dff0ffba53abb444abd381562ce3fb7ab..4ad91d66b183e3fd46394a81d3bf773e536d6d23 100644 (file)
@@ -17,7 +17,6 @@
 // Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 
 
-#include "AIScenario.hxx"
 #include <simgear/misc/sg_path.hxx>
 #include <simgear/debug/logstream.hxx>
 #include <simgear/structure/exception.hxx>
 #  define exception c_exception
 #endif
 #include <simgear/props/props.hxx>
+
 #include <Main/globals.hxx>
 #include <Main/fg_props.hxx>
 
+#include "AIScenario.hxx"
+
+
 
 FGAIScenario::FGAIScenario(string filename)
 {
@@ -49,13 +52,13 @@ FGAIScenario::FGAIScenario(string filename)
   SGPropertyNode * node = root.getNode("scenario");
   for (i = 0; i < node->nChildren(); i++) { 
      //cout << "Reading entry " << i << endl;        
-     entry* en = new entry;
+     FGAIModelEntity* en = new FGAIModelEntity;
      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->m_type         = entry_node->getStringValue("type", "aircraft");
+     en->m_class        = entry_node->getStringValue("class", "jet_transport");
+     en->path           = entry_node->getStringValue("model", "Models/Geometry/glider.ac");
      en->flightplan     = entry_node->getStringValue("flightplan", "");
      en->repeat         = entry_node->getDoubleValue("repeat", 0.0); 
      en->latitude       = entry_node->getDoubleValue("latitude", 0.0); 
@@ -88,7 +91,7 @@ FGAIScenario::~FGAIScenario()
 }
 
 
-FGAIScenario::entry*
+FGAIModelEntity*
 FGAIScenario::getNextEntry( void )
 {
   if (entries.size() == 0) return 0;
index 5118ddf6e6eec0c704e783e4fdc0055d7887b86d..424b449706a91b69b31bf767637bcf3559ee4d47 100644 (file)
 #define _FG_AISCENARIO_HXX
 
 #include <simgear/compiler.h>
+
 #include <vector>
 #include <string>
+
+#include "AIBase.hxx"
+
 SG_USING_STD(vector);
 SG_USING_STD(string);
 
@@ -30,41 +34,15 @@ class FGAIScenario {
 
 public:
 
-  typedef struct {
-   string callsign;
-   string aitype;       // can be aircraft, ship, storm, thermal, ballistic, smoke
-   string aircraft_class;
-   string model_path;
-   string flightplan;
-   double repeat;             // in seconds
-   double latitude;           // used if no flightplan defined
-   double longitude;          // used if no flightplan defined
-   double altitude;           // used if no flightplan defined
-   double speed;              // used if no flightplan defined
-   double heading;            // used if no flightplan defined
-   double roll;               // used if no flightplan defined
-   double azimuth;            // used by ballistic objects
-   double elevation;          // used by ballistic objects
-   double rudder;             // used by ship objects 
-   double strength;           // used by thermal objects
-   double diameter;           // used by thermal objects
-   double eda;                // used by ballistic objects
-   double life;               // life span in seconds
-   double buoyancy;           // acceleration in ft per sec2
-   double wind_from_east;     // in feet per second
-   double wind_from_north;    // in feet per second
-   bool wind;
-  } entry;
-
    FGAIScenario(string filename);
    ~FGAIScenario();
 
-   entry* getNextEntry( void );
+   FGAIModelEntity* getNextEntry( void );
    int nEntries( void );
 
 private:
 
-    typedef vector <entry*> entry_vector_type;
+    typedef vector <FGAIModelEntity*> entry_vector_type;
     typedef entry_vector_type::iterator entry_vector_iterator;
 
     entry_vector_type       entries;
index 47c2a2cd7bfdab4f594bbf950a2025f903c33eb6..58f38190f8dc14270426a63d79dd0ac83889e132 100644 (file)
@@ -92,11 +92,23 @@ SubmodelSystem::release (submodel* sm, double dt)
   transform(sm);
 
   //cout << "Creating a submodel." << endl; 
-  int rval = ai->createBallistic( sm->model, IC.lat, IC.lon, IC.alt, IC.azimuth,
-                                  IC.elevation, IC.speed, 
-                                 sm->drag_area, sm->life,
-                                 sm->buoyancy,
-                                 IC.wind_from_east, IC.wind_from_north, sm->wind);
+  FGAIModelEntity entity;
+
+  entity.path = sm->model.c_str();
+  entity.latitude = IC.lat;
+  entity.longitude = IC.lon;
+  entity.altitude = IC.alt;
+  entity.azimuth = IC.azimuth;
+  entity.elevation = IC.elevation;
+  entity.speed = IC.speed;
+  entity.eda = sm->drag_area;
+  entity.life = sm->life;
+  entity.buoyancy = sm->buoyancy;
+  entity.wind_from_east = IC.wind_from_east;
+  entity.wind_from_north = IC.wind_from_north;
+  entity.wind = sm->wind;
+  int rval = ai->createBallistic( &entity );
+
   //cout << "Submodel created." << endl;
   if (sm->count > 0) (sm->count)--; 
 
index 7e8c38188c1af29aa697ad5d9b9dd00049a0c6d0..56e3ac8549118a96f333531c6e8bb78244f379b0 100644 (file)
@@ -13,7 +13,7 @@
 
 #include <simgear/props/props.hxx>
 #include <simgear/structure/subsystem_mgr.hxx>
-#include <AIModel/AIManager.hxx>
+#include <AIModel/AIBase.hxx>
 #include <vector>
 #include <string>
 SG_USING_STD(vector);
index 89613021b1faf61ec279d27e01df6c2fe6e9df27..dbe0e2845cb995a3aa2676e8195e4639d2602dae 100644 (file)
@@ -258,20 +258,20 @@ void FGAISchedule::update(time_t now)
              string flightPlanName = dep->id + string("-") + arr->id + 
                string(".xml");
 
-             FGAIFlightPlan* f;
-             f = new FGAIFlightPlan(flightPlanName, 
-                                    lat, 
-                                    lon,
-                                    i->getCruiseAlt() * 100, // convert from FL to feet
-                                    //speed, 
-                                    450,
-                                    courseToDest,
-                                    dep,
-                                    arr);
+              FGAIModelEntity entity;
+
+              entity.m_class = "jet_transport";
+              entity.path = modelPath.c_str();
+              entity.flightplan = flightPlanName.c_str();
+              entity.latitude = lat;
+              entity.longitude = lon;
+              entity.altitude = i->getCruiseAlt() * 100; // convert from FL to feet
+              entity.speed = 450;
+             entity.fp = new FGAIFlightPlan(&entity, courseToDest, dep, arr);
+
              // Fixme: A non-existent model path results in an
              // abort, due to an unhandled exeption, in fg main loop.
-             AIManagerRef = aimgr->createAircraft("jet_transport", 
-                                              modelPath, f); 
+             AIManagerRef = aimgr->createAircraft( &entity );
              //cerr << "Created: " << AIManagerRef << endl;
            }
          return;
index 07f804b2b80b385710f4bb9d0f04f2879cc95d88..dda17c06bdf8be601c2bb3ec25496a70840092da 100644 (file)
@@ -53,7 +53,7 @@
 #include <simgear/xml/easyxml.hxx>
 
 #include <AIModel/AIFlightPlan.hxx>
-#include <AIModel/AIManager.hxx>
+#include <AIModel/AIBase.hxx>
 #include <Airports/simple.hxx>
 #include <Main/fg_init.hxx>   // That's pretty ugly, but I need fgFindAirportID