// along with this program; if not, write to the Free Software
// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
-#include <Main/fgfs.hxx>
+#include <simgear/misc/sg_path.hxx>
+
#include <Main/fg_props.hxx>
#include <Main/globals.hxx>
-#include <simgear/misc/sg_path.hxx>
#include <list>
FGAIMgr::FGAIMgr() {
ATC = globals->get_ATC_mgr();
+ initDone = false;
}
FGAIMgr::~FGAIMgr() {
path_str = dir + "\\*.*";
if ( ( hfile = _findfirst( path.c_str(), &de ) ) == -1 ) {
- cout << "cannot open directory " << dir << "\n";
+ SG_LOG(SG_ATC, SG_WARN, "cannot open directory " << dir);
} else {
// load all .taxi files
do {
pos = file.find(".");
ext = file.substr(pos + 1);
if(ext == "taxi") {
- cout << "TAXI FILE FOUND!!!\n";
f_ident = file.substr(0, pos);
FGAirport a;
if(dclFindAirportID(f_ident, &a)) {
apts->push_back(f_ident);
airports[idx] = apts;
}
- cout << "Mapping " << f_ident << " to bucket " << idx << '\n';
+ SG_LOG(SG_ATC, SG_BULK, "Mapping " << f_ident << " to bucket " << idx);
}
}
} while ( _findnext( hfile, &de ) == 0 );
struct dirent *de;
if ( (d = opendir( dir.c_str() )) == NULL ) {
- cout << "cannot open directory " << dir << "\n";
+ SG_LOG(SG_ATC, SG_WARN, "cannot open directory " << dir);
} else {
- cout << "Opened directory " << dir << " OK :-)\n";
- cout << "Contents are:\n";
// load all .taxi files
while ( (de = readdir(d)) != NULL ) {
file = de->d_name;
pos = file.find(".");
- cout << file << '\n';
-
ext = file.substr(pos + 1);
if(ext == "taxi") {
- cout << "TAXI FILE FOUND!!!\n";
f_ident = file.substr(0, pos);
FGAirport a;
if(dclFindAirportID(f_ident, &a)) {
apts->push_back(f_ident);
airports[idx] = apts;
}
- cout << "Mapping " << f_ident << " to bucket " << idx << '\n';
+ SG_LOG(SG_ATC, SG_BULK, "Mapping " << f_ident << " to bucket " << idx);
}
}
}
// See if are in range at startup and activate if necessary
SearchByPos(10.0);
+
+ initDone = true;
}
void FGAIMgr::bind() {
}
void FGAIMgr::update(double dt) {
+ if(!initDone) {
+ init();
+ SG_LOG(SG_ATC, SG_WARN, "Warning - AIMgr::update(...) called before AIMgr::init()");
+ }
+
static int i = 0;
static int j = 0;