+ 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");
+ if (path.exists())
+ 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