diff --git a/src/Traffic/Schedule.cxx b/src/Traffic/Schedule.cxx index 6692c8cc8..cc117304a 100644 --- a/src/Traffic/Schedule.cxx +++ b/src/Traffic/Schedule.cxx @@ -235,6 +235,7 @@ bool FGAISchedule::update(time_t now) if (!deptime) deptime = (*flights.begin())->getDepartureTime(); FGScheduledFlightVecIterator i = flights.begin(); + SG_LOG (SG_GENERAL, SG_INFO,"Processing registration " << registration << " with callsign " << (*i)->getCallSign()) if (AIManagerRef) { // Check if this aircraft has been released. @@ -263,7 +264,6 @@ bool FGAISchedule::update(time_t now) // object for it. //if ((i->getDepartureTime() < now) && (i->getArrivalTime() > now)) - // Part of this flight is in the future. if ((*i)->getArrivalTime() > now) { diff --git a/src/Traffic/TrafficMgr.cxx b/src/Traffic/TrafficMgr.cxx index e26537236..dd42d52f3 100644 --- a/src/Traffic/TrafficMgr.cxx +++ b/src/Traffic/TrafficMgr.cxx @@ -49,6 +49,7 @@ #include #include +#include #include #include @@ -114,6 +115,51 @@ void FGTrafficManager::init() // } // Sort by points: Aircraft with frequent visits to the // startup airport will be processed first + ulDir* d, *d2; + ulDirEnt* dent, *dent2; + SGPath aircraftDir = globals->get_fg_root(); + + /* keep the following three lines (which mimicks the old "fixed path" behavior) + * until we have some AI models with traffic in the base package + */ + SGPath path = aircraftDir; + path.append("/Traffic/fgtraffic.xml"); + readXML(path.str(),*this); + + aircraftDir.append("AI/Aircraft/"); + if (aircraftDir.exists()) + { + if((d = ulOpenDir(aircraftDir.c_str())) == NULL) + return; + while((dent = ulReadDir(d)) != NULL) { + //cerr << "Scanning : " << dent->d_name << endl; + if (string(dent->d_name) != string(".") && + string(dent->d_name) != string("..") && + dent->d_isdir) + { + SGPath currACDir = aircraftDir; + currACDir.append(dent->d_name); + if ((d2 = ulOpenDir(currACDir.c_str())) == NULL) + return; + while ((dent2 = ulReadDir(d2)) != NULL) { + SGPath currFile = currACDir; + currFile.append(dent2->d_name); + if (currFile.extension() == string("xml")) + { + //cerr << "found " << dent2->d_name << " for parsing" << endl; + SGPath currFile = currACDir; + currFile.append(dent2->d_name); + SG_LOG(SG_GENERAL, SG_INFO, "Scanning " << currFile.str() << " for traffic"); + readXML(currFile.str(),*this); + } + } + ulCloseDir(d2); + } + } + ulCloseDir(d); + } + // Sort by points: Aircraft with frequent visits to the + // startup airport will be processed first sort(scheduledAircraft.begin(), scheduledAircraft.end(), compareSchedules); currAircraft = scheduledAircraft.begin(); currAircraftClosest = scheduledAircraft.begin(); @@ -122,14 +168,17 @@ void FGTrafficManager::init() void FGTrafficManager::update(double something) { + //SG_LOG( SG_GENERAL, SG_INFO, "Running TrafficManager::Update() "); if (runCount < 1000) { runCount++; return; } time_t now = time(NULL) + fgGetLong("/sim/time/warp"); - if (scheduledAircraft.size() == 0) + if (scheduledAircraft.size() == 0) { + //SG_LOG( SG_GENERAL, SG_INFO, "Returned Running TrafficManager::Update() "); return; + } if(currAircraft == scheduledAircraft.end()) { //cerr << "resetting schedule " << endl; @@ -142,6 +191,7 @@ void FGTrafficManager::update(double something) cerr << "Failed to update aircraft schedule in traffic manager" << endl; } currAircraft++; + //SG_LOG( SG_GENERAL, SG_INFO, "Done Running TrafficManager::Update() "); } void FGTrafficManager::release(int id)