]> git.mxchange.org Git - flightgear.git/blobdiff - src/Airports/dynamics.cxx
Fix for refueling and radar calculations.
[flightgear.git] / src / Airports / dynamics.cxx
index 4e3384e64e7c666c232249cf6b178d230f44d5da..3f6185df20e63ef4120b76a386eac598b964c7da 100644 (file)
@@ -39,7 +39,6 @@
 #include <Main/globals.hxx>
 #include <Main/fg_props.hxx>
 #include <Airports/runways.hxx>
-#include <simgear/xml/easyxml.hxx>
 
 #include STL_STRING
 #include <vector>
@@ -49,16 +48,13 @@ SG_USING_STD(vector);
 SG_USING_STD(sort);
 SG_USING_STD(random_shuffle);
 
-#include "parking.hxx"
-#include "groundnetwork.hxx"
-#include "runwayprefs.hxx"
 #include "dynamics.hxx"
 
 /********** FGAirport Dynamics *********************************************/
 
 FGAirportDynamics::FGAirportDynamics(double lat, double lon, double elev, string id) :
-  _latitude(lat),
   _longitude(lon),
+  _latitude(lat),
   _elevation(elev),
   _id(id)
 {
@@ -95,7 +91,6 @@ FGAirportDynamics::FGAirportDynamics(const FGAirportDynamics& other)
 // Destructor
 FGAirportDynamics::~FGAirportDynamics()
 {
-  
 }
 
 
@@ -113,6 +108,7 @@ void FGAirportDynamics::init()
   // add the gate positions to the ground network. 
   groundNetwork.addNodes(&parkings);
   groundNetwork.init();
+  groundNetwork .setTowerController(&towerController);
 }
 
 bool FGAirportDynamics::getAvailableParking(double *lat, double *lon, double *heading, int *gateId, double rad, const string &flType, const string &acType, const string &airline)
@@ -165,11 +161,19 @@ bool FGAirportDynamics::getAvailableParking(double *lat, double *lon, double *he
              continue;
            }
          else // Airline code doesn't match
-           if (i->getCodes().find(airline, 0) == string::npos)
-             {
-               available = false;
-               continue;
-             }
+           {
+             //cerr << "Code = " << airline << ": Codes " << i->getCodes();
+             if (i->getCodes().find(airline, 0) == string::npos)
+               {
+                 available = false;
+                 //cerr << "Unavailable" << endl;
+                 continue;
+               }
+             else
+               {
+                 //cerr << "Available" << endl;
+               }
+           }
          // Type doesn't match
          if (i->getType() != flType)
            {
@@ -297,7 +301,7 @@ void FGAirportDynamics::getParking (int id, double *lat, double* lon, double *he
            {
              *lat     = i->getLatitude();
              *lon     = i->getLongitude();
-             *heading = i->getLongitude();
+             *heading = i->getHeading();
            }
        }
     }
@@ -437,13 +441,11 @@ void  FGAirportDynamics::pi (const char * target, const char * data) {
 }
 
 void  FGAirportDynamics::warning (const char * message, int line, int column) {
-  cout << "Warning: " << message << " (" << line << ',' << column << ')'   
-       << endl;
+  SG_LOG(SG_IO, SG_WARN, "Warning: " << message << " (" << line << ',' << column << ')');
 }
 
 void  FGAirportDynamics::error (const char * message, int line, int column) {
-  cout << "Error: " << message << " (" << line << ',' << column << ')'
-       << endl;
+  SG_LOG(SG_IO, SG_ALERT, "Error: " << message << " (" << line << ',' << column << ')');
 }
 
 void FGAirportDynamics::setRwyUse(const FGRunwayPreference& ref)
@@ -471,11 +473,11 @@ void FGAirportDynamics::getActiveRunway(const string &trafficType, int action, s
       RunwayGroup *currRunwayGroup = 0;
       int nrActiveRunways = 0;
       time_t dayStart = fgGetLong("/sim/time/utc/day-seconds");
-      if (((dayStart - lastUpdate) > 600) || trafficType != prevTrafficType)
+      if ((abs((long)(dayStart - lastUpdate)) > 600) || trafficType != prevTrafficType)
        {
          landing.clear();
          takeoff.clear();
-         //lastUpdate = dayStart;
+         lastUpdate = dayStart;
          prevTrafficType = trafficType;
 
          FGEnvironment