}
FGAIMgr::~FGAIMgr() {
- _defaultModel->deRef();
- if(_havePiperModel) _piperModel->deRef();
+ ssgDeRefDelete(_defaultModel);
+ if(_havePiperModel) ssgDeRefDelete(_piperModel);
}
void FGAIMgr::init() {
// Load up models at the start to avoid pausing later
// Hack alert - Hardwired paths!!
- string planepath = "Aircraft/c172r/Models/c172-dpm.ac";
+ string planepath = "Aircraft/c172p/Models/c172p.xml";
bool _loadedDefaultOK = true;
try {
_defaultModel = sgLoad3DModel( globals->get_fg_root(),
//cout << "Size of AI list is " << ai_list.size() << '\n';
}
-void FGAIMgr::ScheduleRemoval(string s) {
+void FGAIMgr::ScheduleRemoval(const string& s) {
//cout << "Scheduling removal of plane " << s << " from AIMgr\n";
removalList.push_back(s);
}
// Activate AI traffic at an airport
-void FGAIMgr::ActivateAirport(string ident) {
+void FGAIMgr::ActivateAirport(const string& ident) {
ATC->AIRegisterAirport(ident);
// TODO - need to start the traffic more randomly
FGAILocalTraffic* local_traffic = new FGAILocalTraffic;
}
// Hack - Generate AI traffic at an airport with no facilities file
-void FGAIMgr::GenerateSimpleAirportTraffic(string ident, double min_dist) {
+void FGAIMgr::GenerateSimpleAirportTraffic(const string& ident, double min_dist) {
// Ugly hack - don't let VFR Cessnas operate at a hardwired list of major airports
// This will go eventually once airport .xml files specify the traffic profile
if(ident == "KSFO" || ident == "KDFW" || ident == "EGLL" || ident == "KORD" || ident == "KJFK"
bool cessna = true;
// Get the time and only operate VFR in the (approximate) daytime.
- //SGTime *t = globals->get_time_params();
- string time_str = fgGetString("sim/time/gmt-string");
- int loc_time = atoi((time_str.substr(0,3)).c_str());
- //cout << "gmt_time = " << loc_time << '\n';
- loc_time += (int)((aptpos.lon() / 360.0) * 24.0);
- while(loc_time < 0) loc_time += 24;
- while(loc_time > 24) loc_time -= 24;
+ struct tm *t = globals->get_time_params()->getGmt();
+ int loc_time = t->tm_hour + int(aptpos.lon() / (360.0 / 24.0));
+ while (loc_time < 0)
+ loc_time += 24;
+ while (loc_time >= 24)
+ loc_time -= 24;
+
//cout << "loc_time = " << loc_time << '\n';
if(loc_time < 7 || loc_time > 19) return;
/*
// Generate a VFR arrival at airport apt, at least distance d (meters) out.
-void FGAIMgr::GenerateVFRArrival(string apt, double d) {
+void FGAIMgr::GenerateVFRArrival(const string& apt, double d) {
}
*/
}
// This will be moved somewhere else eventually!!!!
-string FGAIMgr::GenerateShortForm(string callsign, string plane_str, bool local) {
+string FGAIMgr::GenerateShortForm(const string& callsign, const string& plane_str, bool local) {
//cout << callsign << '\n';
string s;
if(local) s = "Trainer-";