]> git.mxchange.org Git - flightgear.git/blobdiff - src/Traffic/Schedule.cxx
properly add librt when clock_gettime is used
[flightgear.git] / src / Traffic / Schedule.cxx
index 1af0ca112a130b60a0a8ecce2100b22b3c8af966..85343db293fb8d605537eb8e2aea936ec8f06b6e 100644 (file)
@@ -228,7 +228,7 @@ bool FGAISchedule::update(time_t now, const SGVec3d& userCart)
     
   if (AIManagerRef) {
     // Check if this aircraft has been released. 
-    FGTrafficManager *tmgr = (FGTrafficManager *) globals->get_subsystem("Traffic Manager");
+    FGTrafficManager *tmgr = (FGTrafficManager *) globals->get_subsystem("traffic-manager");
     if (tmgr->isReleased(AIManagerRef)) {
       AIManagerRef = 0;
     } else {
@@ -347,7 +347,7 @@ bool FGAISchedule::createAIAircraft(FGScheduledFlight* flight, double speedKnots
                                             airline);
   if (fp->isValidPlan()) {
         aircraft->SetFlightPlan(fp);
-        FGAIManager* aimgr = (FGAIManager *) globals-> get_subsystem("ai_model");
+        FGAIManager* aimgr = (FGAIManager *) globals-> get_subsystem("ai-model");
         aimgr->attach(aircraft);
         AIManagerRef = aircraft->getID();
         return true;
@@ -374,27 +374,24 @@ void FGAISchedule::scheduleFlights(time_t now)
   if (!flights.empty()) {
     return;
   }
-  string startingPort;
+  //string startingPort;
   string userPort = fgGetString("/sim/presets/airport-id");
   SG_LOG(SG_GENERAL, SG_BULK, "Scheduling Flights for : " << modelPath << " " <<  registration << " " << homePort);
   FGScheduledFlight *flight = NULL;
   do {
     if (currentDestination.empty()) {
-        //flight = findAvailableFlight(userPort, flightIdentifier, now, (now+1800));
+        flight = findAvailableFlight(userPort, flightIdentifier, now, (now+6400));
         if (!flight)
             flight = findAvailableFlight(currentDestination, flightIdentifier);
     } else {
         flight = findAvailableFlight(currentDestination, flightIdentifier);
     }
-    
     if (!flight) {
       break;
     }
-    if (startingPort.empty()) {
-        startingPort = flight->getDepartureAirport()->getId();
-    }
-
-   
+    //if (startingPort.empty()) {
+    //    startingPort = flight->getDepartureAirport()->getId();
+    //}
     currentDestination = flight->getArrivalAirport()->getId();
     //cerr << "Current destination " <<  currentDestination << endl;
     if (!initialized) {
@@ -402,7 +399,10 @@ void FGAISchedule::scheduleFlights(time_t now)
        //cerr << "Scheduled " << registration <<  " " << score << " for Flight " 
        //     << flight-> getCallSign() << " from " << departurePort << " to " << currentDestination << endl;
         if (userPort == departurePort) {
+            lastRun = 1;
             hits++;
+        } else {
+            lastRun = 0;
         }
         //runCount++;
         initialized = true;
@@ -423,7 +423,7 @@ void FGAISchedule::scheduleFlights(time_t now)
                              << "  "        << arrT << ":");
   
     flights.push_back(flight);
-  } while (currentDestination != startingPort);
+  } while (currentDestination != homePort);
   SG_LOG(SG_GENERAL, SG_BULK, " Done ");
 }
 
@@ -465,7 +465,7 @@ FGScheduledFlight* FGAISchedule::findAvailableFlight (const string &currentDesti
 {
     time_t now = time(NULL) + fgGetLong("/sim/time/warp");
 
-    FGTrafficManager *tmgr = (FGTrafficManager *) globals->get_subsystem("Traffic Manager");
+    FGTrafficManager *tmgr = (FGTrafficManager *) globals->get_subsystem("traffic-manager");
     FGScheduledFlightVecIterator fltBegin, fltEnd;
     fltBegin = tmgr->getFirstFlight(req);
     fltEnd   = tmgr->getLastFlight(req);