]> git.mxchange.org Git - flightgear.git/commitdiff
ATC/Traffic doesn’t crash reset.
authorJames Turner <zakalawe@mac.com>
Fri, 11 Dec 2015 18:11:46 +0000 (12:11 -0600)
committerJames Turner <zakalawe@mac.com>
Fri, 11 Dec 2015 18:11:59 +0000 (12:11 -0600)
- remove some global headers from AI headers, to avoid pollution
- change how ATC owns the ‘player’ FGAIAircraft so reset works
- ensure AIAircraft controllers are cleared on unbind for reset

28 files changed:
src/AIModel/AIAircraft.cxx
src/AIModel/AIAircraft.hxx
src/AIModel/AIBallistic.cxx
src/AIModel/AIBase.cxx
src/AIModel/AIBase.hxx
src/AIModel/AICarrier.cxx
src/AIModel/AIEscort.cxx
src/AIModel/AIFlightPlan.cxx
src/AIModel/AIFlightPlanCreate.cxx
src/AIModel/AIFlightPlanCreateCruise.cxx
src/AIModel/AIGroundVehicle.cxx
src/AIModel/AIManager.cxx
src/AIModel/AIManager.hxx
src/AIModel/AIMultiplayer.cxx
src/AIModel/AIShip.cxx
src/AIModel/AIWingman.cxx
src/ATC/GroundController.cxx
src/ATC/atc_mgr.cxx
src/ATC/atc_mgr.hxx
src/GUI/MapWidget.cxx
src/Main/fg_init.cxx
src/Network/RemoteXMLRequest.hxx
src/Scenery/tilemgr.cxx
src/Scenery/tilemgr.hxx
src/Traffic/SchedFlight.cxx
src/Traffic/Schedule.cxx
src/Traffic/Schedule.hxx
src/Traffic/TrafficMgr.cxx

index b7967a5af785788951871f6b2e5ab2c04c9d3857..285c3fee80f6efe85c3288ac85ae12db8dec696a 100644 (file)
@@ -29,6 +29,7 @@
 #include <Airports/dynamics.hxx>
 #include <Airports/airport.hxx>
 #include <Main/util.hxx>
+#include <Traffic/Schedule.hxx>
 
 #include <simgear/structure/exception.hxx>
 
@@ -39,7 +40,9 @@
 // defined in AIShip.cxx
 extern double fgIsFinite(double x);
 
+#include "AIManager.hxx"
 #include "AIAircraft.hxx"
+#include "AIFlightPlan.hxx"
 #include "performancedata.hxx"
 #include "performancedb.hxx"
 #include <signal.h>
@@ -133,6 +136,12 @@ void FGAIAircraft::update(double dt) {
     Transform();
 }
 
+void FGAIAircraft::unbind()
+{
+    FGAIBase::unbind();
+    clearATCController();
+}
+
 void FGAIAircraft::setPerformance(const std::string& acType, const std::string& acclass)
 {
   static PerformanceDB perfdb; //TODO make it a global service
@@ -408,6 +417,13 @@ double FGAIAircraft::calcVerticalSpeed(double vert_ft, double dist_m, double spe
     return vs;
 }
 
+void FGAIAircraft::clearATCController()
+{
+    controller = 0;
+    prevController = 0;
+    towerController = 0;
+}
+
 void FGAIAircraft::assertSpeed(double speed)
 {
     if ((speed < -50) || (speed > 1000)) {
index 3ad8b8a67130db4a779e2e0ef76b2dbb817cc3e4..a3bb4d6d20d6263916c6c30318519969395895be 100644 (file)
 #ifndef _FG_AIAircraft_HXX
 #define _FG_AIAircraft_HXX
 
-#include "AIManager.hxx"
 #include "AIBase.hxx"
 
-#include <Traffic/SchedFlight.hxx>
-#include <Traffic/Schedule.hxx>
-#include <ATC/trafficcontrol.hxx>
-
 #include <string>
 
 class PerformanceData;
+class FGAISchedule;
+class FGAIFlightPlan;
+class FGATCController;
+class FGATCInstruction;
+class FGAIWaypoint;
 
 class FGAIAircraft : public FGAIBase {
 
@@ -43,6 +43,7 @@ public:
     // virtual bool init(bool search_in_AI_path=false);
     virtual void bind();
     virtual void update(double dt);
+    virtual void unbind();
 
     void setPerformance(const std::string& acType, const std::string& perfString);
   //  void setPerformance(PerformanceData *ps);
@@ -108,12 +109,13 @@ public:
 
     FGATCController * getATCController() { return controller; };
     
+    void clearATCController();
 protected:
     void Run(double dt);
 
 private:
     FGAISchedule *trafficRef;
-    FGATCController *controller, 
+    FGATCController *controller,
                     *prevController,
                     *towerController; // Only needed to make a pre-announcement
 
index be5bcd74f3696c8aa6b4292bd281b99b43514815..3a8eb46e4d646ec4dd48a88eb9133bb31a55cc00 100644 (file)
@@ -33,6 +33,7 @@
 
 #include <Main/util.hxx>
 #include <Environment/gravity.hxx>
+#include <Main/fg_props.hxx>
 
 using namespace simgear;
 using std::string;
index d933e68af0380fba264d42a4c8ac1c26288d2119..51146e077ee64c6713e36df0724348809120ef79 100644 (file)
 #include <simgear/props/props.hxx>
 
 #include <Main/globals.hxx>
+#include <Main/fg_props.hxx>
 #include <Scenery/scenery.hxx>
 #include <Scripting/NasalSys.hxx>
 #include <Scripting/NasalModelData.hxx>
 #include <Sound/fg_fx.hxx>
 
+#include "AIFlightPlan.hxx"
 #include "AIBase.hxx"
 #include "AIManager.hxx"
 
@@ -219,7 +221,7 @@ FGAIBase::removeModel()
         return;
 
     FGScenery* pSceneryManager = globals->get_scenery();
-    if (pSceneryManager)
+    if (pSceneryManager && pSceneryManager->get_models_branch())
     {
         osg::ref_ptr<osg::Object> temp = _model.get();
         pSceneryManager->get_models_branch()->removeChild(aip.getSceneGraph());
index f2ba097e7ef4b087fd96b91795fcc11743eb7f45..da27569c17de424cfb66bc5cccefd8f62ab692be 100644 (file)
@@ -33,8 +33,6 @@
 
 #include <simgear/math/sg_geodesy.hxx>
 
-#include <Main/fg_props.hxx>
-
 namespace osg { class PagedLOD; }
 
 namespace simgear {
@@ -325,6 +323,8 @@ public:
     std::string & getCallSign();
 };
 
+typedef SGSharedPtr<FGAIBase> FGAIBasePtr;
+
 inline void FGAIBase::setManager(FGAIManager* mgr, SGPropertyNode* p) {
     manager = mgr;
     props = p;
index e8639395a69f1926ec44fc5aecd64c992e0e251d..1a0908c93e3c4e7ed8c2af2580723ee76994e8a6 100644 (file)
@@ -30,6 +30,8 @@
 
 #include <cmath>
 #include <Main/util.hxx>
+#include <Main/globals.hxx>
+#include <Main/fg_props.hxx>
 
 #include "AICarrier.hxx"
 
index 44e53c849a29c4e3a05a1423081bf9debafab38e..c2067ae1a353f82dfbc8ff6dfeccf2c650cfe11b 100644 (file)
@@ -32,6 +32,7 @@
 
 #include <cmath>
 #include <Main/util.hxx>
+#include <Main/globals.hxx>
 #include <Viewer/viewer.hxx>
 
 #include <Scenery/scenery.hxx>
index 99f68eb96884db65a9f2ede87c6aea6552772c9e..b295310c6cdcefe91beb83298c373edb8b22bbb9 100644 (file)
@@ -41,6 +41,8 @@
 #include <Environment/environment_mgr.hxx>
 #include <Environment/environment.hxx>
 
+#include <Traffic/Schedule.hxx>
+
 #include "AIFlightPlan.hxx"
 #include "AIAircraft.hxx"
 
index 9688c391bd944cdfd7ebe07fe1bedbb779cfa26e..59d4422601fe900a7b4a2c12b9f131097d942762 100644 (file)
 #include "AIAircraft.hxx"
 #include "performancedata.hxx"
 
+#include <Main/fg_props.hxx>
 #include <Environment/environment_mgr.hxx>
 #include <Environment/environment.hxx>
 #include <FDM/LaRCsim/basic_aero.h>
 #include <Navaids/navrecord.hxx>
+#include <Traffic/Schedule.hxx>
 
 using std::string;
 
index 709378f90013bc8d16d5278b4e21962b99f39f8d..66639444b6ca2479c74e907c9ecf619a664ef323 100644 (file)
@@ -33,6 +33,8 @@
 #include <Environment/environment_mgr.hxx>
 #include <Environment/environment.hxx>
 
+#include <Traffic/Schedule.hxx>
+
 #include "AIFlightPlan.hxx"
 #include "AIAircraft.hxx"
 #include "performancedata.hxx"
index 15424079e9bd6448960444764762875add4269a9..2ef662e09dc8eaf3eaea2515b408e6b04efb4de0 100644 (file)
@@ -27,6 +27,7 @@
 #include <Viewer/viewer.hxx>
 #include <Scenery/scenery.hxx>
 #include <Airports/dynamics.hxx>
+#include <Main/globals.hxx>
 
 #include "AIGroundVehicle.hxx"
 
index 2c6fc15f455da60077324fc6f535831a90cb2532..4faf23e591e5887ffb0937ad15f276d40028e67c 100644 (file)
@@ -32,6 +32,7 @@
 #include <boost/foreach.hpp>
 
 #include <Main/globals.hxx>
+#include <Main/fg_props.hxx>
 #include <Airports/airport.hxx>
 #include <Scripting/NasalSys.hxx>
 
index a35f64968ddb802c2f76af3eeb6ad5403dd1fb6c..6caa098f3c24478debb09e339a516ff74ef41977 100644 (file)
 
 #include <simgear/structure/subsystem_mgr.hxx>
 #include <simgear/structure/SGSharedPtr.hxx>
-#include <simgear/props/props_io.hxx>
-
-#include <Main/fg_props.hxx>
-
-#include <AIModel/AIBase.hxx>
-#include <AIModel/AIFlightPlan.hxx>
-
-#include <Traffic/SchedFlight.hxx>
-#include <Traffic/Schedule.hxx>
 
+class FGAIBase;
 class FGAIThermal;
 
 typedef SGSharedPtr<FGAIBase> FGAIBasePtr;
@@ -84,6 +76,8 @@ public:
      * corresponding AIObject implementation, or NULL.
      */
     FGAIBasePtr getObjectFromProperty(const SGPropertyNode* aProp) const;
+
+    static const char* subsystemName() { return "ai-model"; }
 private:
     // FGSubmodelMgr is a friend for access to the AI_list
     friend class FGSubmodelMgr;
index 6e80f3776a122d198fad6a1a35959827634c5d02..a4176b3a6d7076fb0e0726a2051384a2dc827251 100644 (file)
@@ -28,6 +28,9 @@
 #include <string>
 #include <stdio.h>
 
+#include <Main/globals.hxx>
+#include <Main/fg_props.hxx>
+
 #include "AIMultiplayer.hxx"
 
 using std::string;
index caea12660f21ef433dd1156ed422938f268e9236..9ec3718bd3000ac9bee1fddb625a492d0c5afb0b 100644 (file)
@@ -37,6 +37,7 @@
 
 #include <simgear/scene/util/SGNodeMasks.hxx>
 #include <Scenery/scenery.hxx>
+#include <Main/globals.hxx>
 
 #include "AIShip.hxx"
 
index 7c14789971ae5079450a561e306e0f2180eee8a7..916830f2801e7dcf12d5502d1c140e77ee795e8c 100644 (file)
@@ -23,6 +23,7 @@
 
 #include <simgear/sg_inlines.h>
 
+#include <Main/fg_props.hxx>
 
 #include "AIWingman.hxx"
 
index 17b8f87f9adeff0d50f17f850d7b9d9348ce6a14..17b06b34060d68cb3cf84991f013b5f8b1288647 100644 (file)
@@ -48,6 +48,8 @@
 #include <Airports/runways.hxx>
 #include <Airports/groundnetwork.hxx>
 
+#include <Main/globals.hxx>
+#include <Main/fg_props.hxx>
 #include <AIModel/AIAircraft.hxx>
 #include <AIModel/performancedata.hxx>
 #include <AIModel/AIFlightPlan.hxx>
index fc5a06c2aba645ba20d1ee59720781f623dddcda..1b32bde4ad392010a6631c9dc5fd6eafa6c998a6 100644 (file)
 #include <Airports/airportdynamicsmanager.hxx>
 #include <Airports/airport.hxx>
 #include <Scenery/scenery.hxx>
+#include <Main/globals.hxx>
+#include <Main/fg_props.hxx>
+#include <AIModel/AIAircraft.hxx>
+#include <Traffic/Schedule.hxx>
+#include <Traffic/SchedFlight.hxx>
+#include <AIModel/AIFlightPlan.hxx>
+
 #include "atc_mgr.hxx"
 
 
@@ -74,12 +81,12 @@ void FGATCManager::init() {
     double speed     = fgGetDouble("/velocities/groundspeed-kt");
     double aircraftRadius = 40; // note that this is currently hardcoded to a one-size-fits all JumboJet value. Should change later;
 
-
-    ai_ac.setCallSign ( callsign  );
-    ai_ac.setLongitude( longitude );
-    ai_ac.setLatitude ( latitude  );
-    ai_ac.setAltitude ( altitude  );
-    ai_ac.setPerformance("", "jet_transport");
+    ai_ac = new FGAIAircraft;
+    ai_ac->setCallSign ( callsign  );
+    ai_ac->setLongitude( longitude );
+    ai_ac->setLatitude ( latitude  );
+    ai_ac->setAltitude ( altitude  );
+    ai_ac->setPerformance("", "jet_transport");
 
     // NEXT UP: Create a traffic Schedule and fill that with appropriate information. This we can use to flight planning.
     // Note that these are currently only defaults. 
@@ -95,7 +102,7 @@ void FGATCManager::init() {
     
     trafficRef->assign(flight);
     FGAIFlightPlan *fp = 0; 
-    ai_ac.setTrafficRef(trafficRef);
+    ai_ac->setTrafficRef(trafficRef);
     
     string flightPlanName = airport + "-" + airport + ".xml";
     //double cruiseAlt = 100; // Doesn't really matter right now.
@@ -127,7 +134,7 @@ void FGATCManager::init() {
             string aircraftType; // Unused.
             string airline;      // Currently used for gate selection, but a fallback mechanism will apply when not specified.
             fp->setGate(pk);
-            if (!(fp->createPushBack(&ai_ac,
+            if (!(fp->createPushBack(ai_ac,
                                      false,
                                      dcs->parent(),
                                      aircraftRadius,
@@ -152,8 +159,8 @@ void FGATCManager::init() {
             leg = 3;
             string fltType = "ga";
             fp->setRunway(runway);
-            fp->createTakeOff(&ai_ac, false, dcs->parent(), 0, fltType);
-            ai_ac.setTakeOffStatus(2);
+            fp->createTakeOff(ai_ac, false, dcs->parent(), 0, fltType);
+            ai_ac->setTakeOffStatus(2);
         } else {
                 // We're on the ground somewhere. Handle this case later.
         }
@@ -170,12 +177,12 @@ void FGATCManager::init() {
     if (fp) {
         fp->restart();
         fp->setLeg(leg);
-        ai_ac.SetFlightPlan(fp);
+        ai_ac->SetFlightPlan(fp);
     }
     if (controller) {
-        controller->announcePosition(ai_ac.getID(), fp, fp->getCurrentWaypoint()->getRouteIndex(),
-                                      ai_ac._getLatitude(), ai_ac._getLongitude(), heading, speed, altitude,
-                                      aircraftRadius, leg, &ai_ac);
+        controller->announcePosition(ai_ac->getID(), fp, fp->getCurrentWaypoint()->getRouteIndex(),
+                                      ai_ac->_getLatitude(), ai_ac->_getLongitude(), heading, speed, altitude,
+                                      aircraftRadius, leg, ai_ac);
 
     //dialog.init();
 
@@ -183,7 +190,14 @@ void FGATCManager::init() {
    //cerr << "Adding groundnetWork to the scenegraph::init" << endl;
    //globals->get_scenery()->get_scene_graph()->addChild(node);
    }
-   initSucceeded = true;
+    initSucceeded = true;
+}
+
+void FGATCManager::shutdown()
+{
+    delete ai_ac;
+    ai_ac = NULL;
+    activeStations.clear();
 }
 
 void FGATCManager::addController(FGATCController *controller) {
@@ -205,7 +219,7 @@ void FGATCManager::update ( double time ) {
    
     
 
-    FGAIFlightPlan *fp = ai_ac.GetFlightPlan();
+    FGAIFlightPlan *fp = ai_ac->GetFlightPlan();
         
     /* test code : find out how the routing develops */
     if (fp) {
@@ -259,20 +273,20 @@ void FGATCManager::update ( double time ) {
     
     cerr << "Bearing to nearest waypoint : " << course1 << " " << dist1 << ". (course " << course2 << ")." <<  endl;
     */
-    ai_ac.setLatitude(latitude);
-    ai_ac.setLongitude(longitude);
-    ai_ac.setAltitude(altitude);
-    ai_ac.setHeading(heading);
-    ai_ac.setSpeed(speed);
-    ai_ac.update(time);
-    controller = ai_ac.getATCController();
+    ai_ac->setLatitude(latitude);
+    ai_ac->setLongitude(longitude);
+    ai_ac->setAltitude(altitude);
+    ai_ac->setHeading(heading);
+    ai_ac->setSpeed(speed);
+    ai_ac->update(time);
+    controller = ai_ac->getATCController();
     FGATCDialogNew::instance()->update(time);
     if (controller) {
        //cerr << "name of previous waypoint : " << fp->getPreviousWaypoint()->getName() << endl;
 
         //cerr << "Running FGATCManager::update()" << endl;
         //cerr << "Currently under control of " << controller->getName() << endl;
-        controller->updateAircraftInformation(ai_ac.getID(),
+        controller->updateAircraftInformation(ai_ac->getID(),
                                               latitude,
                                               longitude,
                                               heading,
index 9f9545730e2ba2e1399dfd12a06788706d45f17d..7091ed778b9968520050efab6e3dd39e203c6ef3 100644 (file)
 #ifndef _ATC_MGR_HXX_
 #define _ATC_MGR_HXX_
 
-//#include <simgear/structure/SGReferenced.hxx>
-//#include <simgear/structure/SGSharedPtr.hxx>
+
 #include <simgear/structure/subsystem_mgr.hxx>
 
 
 #include <ATC/trafficcontrol.hxx>
 #include <ATC/atcdialog.hxx>
 
-#include <AIModel/AIAircraft.hxx>
-//class FGATCController;
+class FGAIAircraft;
 
 
 typedef std::vector<FGATCController*> AtcVec;
@@ -48,7 +46,7 @@ class FGATCManager : public SGSubsystem
 {
 private:
   AtcVec activeStations;
-  FGAIAircraft ai_ac;
+  FGAIAircraft* ai_ac;
   FGATCController *controller, *prevController; // The ATC controller that is responsible for the user's aircraft. 
   bool networkVisible;
   bool initSucceeded;
@@ -58,6 +56,8 @@ public:
   FGATCManager();
   ~FGATCManager();
   void init();
+  virtual void shutdown();
+
   void addController(FGATCController *controller);
   void removeController(FGATCController* controller);
   void update(double time);
index b5237d8a039d0f91cbd0eb3d3c1e2275d6861708..bb44327fb30d49cdd6dd842652e0ecb1af87048a 100644 (file)
@@ -27,6 +27,7 @@
 #include <Navaids/routePath.hxx>
 #include <Aircraft/FlightHistory.hxx>
 #include <AIModel/AIAircraft.hxx>
+#include <AIModel/AIManager.hxx>
 #include <AIModel/AIFlightPlan.hxx>
 
 const char* RULER_LEGEND_KEY = "ruler-legend";
@@ -1977,7 +1978,7 @@ MapWidget::DrawAIObject::DrawAIObject(SGPropertyNode* m, const SGGeod& g) :
         // try to access the flight-plan of the aircraft. There are several layers
         // of potential NULL-ness here, so we have to be defensive at each stage.
         std::string originICAO, destinationICAO;
-        FGAIManager* aiManager = static_cast<FGAIManager*>(globals->get_subsystem("ai-model"));
+        FGAIManager* aiManager = globals->get_subsystem<FGAIManager>();
         FGAIBasePtr aircraft = aiManager ? aiManager->getObjectFromProperty(model) : NULL;
         if (aircraft) {
             FGAIAircraft* p = static_cast<FGAIAircraft*>(aircraft.get());
index d7532557471f4ee79c3fbf310ec410d820162dfd..572ca446a42382cdfca74ba6b032b3c9d1828979 100644 (file)
@@ -1024,7 +1024,7 @@ void fgStartNewReset()
         string_list::const_iterator it;
         for (it = names.begin(); it != names.end(); ++it) {
             if ((*it == "time") || (*it == "terrasync") || (*it == "events")
-                || (*it == "lighting"))
+                || (*it == "lighting") || (*it == FGTileMgr::subsystemName()) || (*it == FGScenery::subsystemName()))
             {
                 continue;
             }
index 239ff4b2b173745d8f7273730470e66566fd5db7..d540db61ae1eb08db07efe1910e2348032ab742d 100644 (file)
 
 #ifndef REMOTEXMLREQUEST_HXXH
 #define REMOTEXMLREQUEST_HXXH
+
 #include <simgear/structure/exception.hxx>
 #include <simgear/io/HTTPMemoryRequest.hxx>
+#include <simgear/props/props_io.hxx>
+
 class RemoteXMLRequest:
   public simgear::HTTP::MemoryRequest
 {
index ec3028d3ea2a4e80d17d0ca7a059515c3012df3f..9c1327b8292cc11505f54386196e926931d666f6 100644 (file)
@@ -126,14 +126,7 @@ FGTileMgr::FGTileMgr():
 
 FGTileMgr::~FGTileMgr()
 {
-    delete _listener;
-    
-    // remove all nodes we might have left behind
-    osg::Group* group = globals->get_scenery()->get_terrain_branch();
-    group->removeChildren(0, group->getNumChildren());
-    // clear OSG cache
-    osgDB::Registry::instance()->clearObjectCache();
-}
+   }
 
 
 // Initialize the Tile Manager subsystem
@@ -142,6 +135,21 @@ void FGTileMgr::init()
     reinit();
 }
 
+void FGTileMgr::shutdown()
+{
+    delete _listener;
+    _listener = NULL;
+
+    FGScenery* scenery = globals->get_scenery();
+    if (scenery && scenery->get_terrain_branch()) {
+        osg::Group* group = scenery->get_terrain_branch();
+        group->removeChildren(0, group->getNumChildren());
+    }
+    // clear OSG cache
+    osgDB::Registry::instance()->clearObjectCache();
+    state = Start; // need to init again
+}
+
 void FGTileMgr::reinit()
 {
     SG_LOG( SG_TERRAIN, SG_INFO, "Initializing Tile Manager subsystem." );
index 37c77888a52d0d79ee74724d61ff662c0eb9c260..6ed281031dce12527d97b9563356bd1eab1b5b2c 100644 (file)
@@ -101,6 +101,8 @@ public:
     // Initialize the Tile Manager
     virtual void init();
     virtual void reinit();
+    virtual void shutdown();
+
     virtual void update(double dt);
 
     const SGBucket& get_current_bucket () const { return current_bucket; }
index 228d67cbf96ad949826696fc995aaee86de7f2b4..7ae4125efcb35d6fd85a7ebbd5d4f2d738599795 100644 (file)
@@ -58,7 +58,6 @@
 #include <AIModel/AIFlightPlan.hxx>
 #include <AIModel/AIManager.hxx>
 #include <Airports/airport.hxx>
-#include <Main/fg_init.hxx>   // That's pretty ugly, but I need fgFindAirportID
 
 
 
index a47dfd2ca3493c2485be2d0b1181736b07747e0d..7e8cdbdfc4aa9e756eb66db24b6a712abbf069bc 100644 (file)
@@ -49,8 +49,8 @@
 #include <AIModel/AIManager.hxx>
 #include <AIModel/AIAircraft.hxx>
 #include <Airports/airport.hxx>
-#include <Main/fg_init.hxx>   // That's pretty ugly, but I need fgFindAirportID
-
+#include <Main/globals.hxx>
+#include <Main/fg_props.hxx>
 
 #include "SchedFlight.hxx"
 #include "TrafficMgr.hxx"
@@ -403,10 +403,12 @@ void FGAISchedule::setHeading()
     courseToDest = SGGeodesy::courseDeg((*flights.begin())->getDepartureAirport()->geod(), (*flights.begin())->getArrivalAirport()->geod());
 }
 
+void FGAISchedule::assign(FGScheduledFlight *ref) { flights.push_back(ref); }
+
 bool FGAISchedule::scheduleFlights(time_t now)
 {
-  //string startingPort;
-  const string& userPort = fgGetString("/sim/presets/airport-id");
+    //string startingPort;
+    const string& userPort = fgGetString("/sim/presets/airport-id");
   SG_LOG(SG_AI, SG_BULK, "Scheduling Flights for : " << modelPath << " " <<  registration << " " << homePort);
   FGScheduledFlight *flight = NULL;
   SGTimeStamp start;
@@ -503,6 +505,18 @@ bool FGAISchedule::next()
    return true;
 }
 
+time_t FGAISchedule::getDepartureTime() { return (*flights.begin())->getDepartureTime   (); }
+
+FGAirport *FGAISchedule::getDepartureAirport() { return (*flights.begin())->getDepartureAirport(); }
+
+FGAirport *FGAISchedule::getArrivalAirport() { return (*flights.begin())->getArrivalAirport  (); }
+
+int FGAISchedule::getCruiseAlt() { return (*flights.begin())->getCruiseAlt       (); }
+
+const std::string &FGAISchedule::getCallSign() { return (*flights.begin())->getCallSign (); }
+
+const std::string &FGAISchedule::getFlightRules() { return (*flights.begin())->getFlightRules (); }
+
 FGScheduledFlight* FGAISchedule::findAvailableFlight (const string &currentDestination,
                                                       const string &req,
                                                      time_t min, time_t max)
index 9ac4b49ead639eabf5c3ca0cf93bd292bac5bbab..12169f4b777843d8598fbc33524bc19c322cca8d 100644 (file)
@@ -34,6 +34,9 @@
 
 // forward decls
 class FGAIAircraft;
+class FGScheduledFlight;
+
+typedef std::vector<FGScheduledFlight*> FGScheduledFlightVec;
 
 class FGAISchedule
 {
@@ -106,18 +109,18 @@ class FGAISchedule
   bool next();   // forces the schedule to move on to the next flight.
 
   // TODO: rework these four functions
-   time_t      getDepartureTime    () { return (*flights.begin())->getDepartureTime   (); };
-  FGAirport * getDepartureAirport () { return (*flights.begin())->getDepartureAirport(); };
-  FGAirport * getArrivalAirport   () { return (*flights.begin())->getArrivalAirport  (); };
-  int         getCruiseAlt        () { return (*flights.begin())->getCruiseAlt       (); };
+  time_t      getDepartureTime    ();
+  FGAirport * getDepartureAirport ();
+  FGAirport * getArrivalAirport   ();
+  int         getCruiseAlt        ();
   double      getRadius           () { return radius; };
   double      getGroundOffset     () { return groundOffset;};
   const std::string& getFlightType     () { return flightType;};
   const std::string& getAirline        () { return airline; };
   const std::string& getAircraft       () { return acType; };
-  const std::string& getCallSign       () { return (*flights.begin())->getCallSign (); };
+  const std::string& getCallSign       ();
   const std::string& getRegistration   () { return registration;};
-  const std::string& getFlightRules    () { return (*flights.begin())->getFlightRules (); };
+  const std::string& getFlightRules    ();
   bool getHeavy                   () { return heavy; };
   double getCourse                () { return courseToDest; };
   unsigned int getRunCount        () { return runCount; };
@@ -128,7 +131,7 @@ class FGAISchedule
   void         setScore   ();
   double       getScore   () { return score; };
   void         setHeading (); 
-  void         assign         (FGScheduledFlight *ref) { flights.push_back(ref); };
+  void         assign         (FGScheduledFlight *ref);
   void         setFlightType  (const std::string& val) { flightType = val; };
   FGScheduledFlight*findAvailableFlight (const std::string& currentDestination, const std::string &req, time_t min=0, time_t max=0);
   // used to sort in descending order of score: I've probably found a better way to
index e17c801cfa03824cf7c5f081895da932b574dcd5..4fc8bd38b675bdfea092bf19cc308e403b7edb4f 100644 (file)
@@ -69,6 +69,8 @@
 #include <AIModel/AIBase.hxx>
 #include <Airports/airport.hxx>
 #include <Main/fg_init.hxx>
+#include <Main/globals.hxx>
+#include <Main/fg_props.hxx>
 
 #include "TrafficMgr.hxx"
 
@@ -391,7 +393,7 @@ private:
   mutable SGMutex _lock;
   bool _isFinished;
   bool _cancelThread;
-  PathList _trafficDirPaths;
+  simgear::PathList _trafficDirPaths;
    
 // parser state
     
@@ -524,7 +526,7 @@ void FGTrafficManager::init()
     
     doingInit = true;
     if (string(fgGetString("/sim/traffic-manager/datafile")).empty()) {
-        PathList dirs = globals->get_data_paths("AI/Traffic");
+        simgear::PathList dirs = globals->get_data_paths("AI/Traffic");
         
         // temporary flag to restrict loading while traffic data is found
         // through terrasync /and/ fgdata. Ultimatley we *do* want to be able to