FGAIFlightPlan::FGAIFlightPlan()
{
- rwy = 0;
sid = 0;
repeat = false;
distance_to_go = 0;
FGAIWaypoint *getLastWaypoint() { return waypoints.back(); };
private:
- FGRunway* rwy;
FGAIFlightPlan *sid;
typedef std::vector <FGAIWaypoint*> wpt_vector_type;
typedef wpt_vector_type::const_iterator wpt_vector_iterator;
apt->getDynamics()->getActiveRunway(rwyClass, 1, activeRunway,
depHeading);
}
- rwy = apt->getRunwayByIdent(activeRunway);
+ FGRunway * rwy = apt->getRunwayByIdent(activeRunway);
+ assert( rwy != NULL );
SGGeod runwayTakeoff = rwy->pointOnCenterline(5.0);
FGGroundNetwork *gn = apt->getDynamics()->getGroundNetwork();
apt->getDynamics()->getActiveRunway(rwyClass, 1, activeRunway,
heading);
}
- rwy = apt->getRunwayByIdent(activeRunway);
-
-
+ FGRunway * rwy = apt->getRunwayByIdent(activeRunway);
+ assert( rwy != NULL );
double airportElev = apt->getElevation();
double heading = ac->getTrafficRef()->getCourse();
apt->getDynamics()->getActiveRunway(rwyClass, 1, activeRunway,
heading);
- rwy = apt->getRunwayByIdent(activeRunway);
}
if (sid) {
for (wpt_vector_iterator i = sid->getFirstWayPoint();
//cerr << " Cloning waypoint " << endl;
}
} else {
+ FGRunway * rwy = apt->getRunwayByIdent(activeRunway);
+ assert( rwy != NULL );
+
SGGeod climb1 = rwy->pointOnCenterline(10 * SG_NM_TO_METER);
wpt = createInAir(ac, "10000ft climb", climb1, vClimb, 10000);
wpt->setGear_down(true);
double heading = ac->getTrafficRef()->getCourse();
apt->getDynamics()->getActiveRunway(rwyClass, 2, activeRunway,
heading);
- rwy = apt->getRunwayByIdent(activeRunway);
-
-
+ FGRunway * rwy = apt->getRunwayByIdent(activeRunway);
+ assert( rwy != NULL );
// Create a slow descent path that ends 250 lateral to the runway.
double initialTurnRadius = getTurnRadius(vDescent, true);
char buffer[12];
for (int i = 1; i < 10; i++) {
snprintf(buffer, 12, "wpt%d", i);
+ FGRunway * rwy = apt->getRunwayByIdent(activeRunway);
+ assert( rwy != NULL );
+
coord = rwy->pointOnCenterline(rwy->lengthM() * (i / 10.0));
wpt = createOnGround(ac, buffer, coord, aptElev, (vTouchdown / i));
wpt->setCrossat(apt->getElevation());
string rwyClass = getRunwayClassFromTrafficType(fltType);
double heading = ac->getTrafficRef()->getCourse();
arr->getDynamics()->getActiveRunway(rwyClass, 2, activeRunway, heading);
- rwy = arr->getRunwayByIdent(activeRunway);
+ FGRunway* rwy = arr->getRunwayByIdent(activeRunway);
+ assert( rwy != NULL );
// begin descent 110km out
SGGeod beginDescentPoint = rwy->pointOnCenterline(0);
SGGeod secondaryDescentPoint = rwy->pointOnCenterline(-10000);
void FGATCManager::init() {
SGSubsystem::init();
- currentATCDialog = new FGATCDialogNew;
- currentATCDialog->init();
int leg = 0;
ai_ac.setSpeed(speed);
ai_ac.update(time);
controller = ai_ac.getATCController();
- currentATCDialog->update(time);
+ FGATCDialogNew::instance()->update(time);
if (controller) {
//cerr << "name of previous waypoint : " << fp->getPreviousWaypoint()->getName() << endl;
AtcVec activeStations;
FGAIAircraft ai_ac;
FGATCController *controller, *prevController; // The ATC controller that is responsible for the user's aircraft.
- //FGATCDialogNew dialog; // note that this variable should really replace the ugly global "currentATCDialog();
bool networkVisible;
bool initSucceeded;
void init();
void addController(FGATCController *controller);
void update(double time);
- FGATCDialogNew * getATCDialog() { return currentATCDialog; };
};
#endif // _ATC_MRG_HXX_
\ No newline at end of file
FGATCDialogNew *currentATCDialog;
-static bool doATCDialog(const SGPropertyNode* arg) {
+/*static bool doATCDialog(const SGPropertyNode* arg) {
//cerr << "Running doATCDialog" << endl;
currentATCDialog->PopupDialog();
return(true);
-}
+}*/
+FGATCDialogNew * FGATCDialogNew::_instance = NULL;
FGATCDialogNew::FGATCDialogNew()
{
void FGATCDialogNew::init() {
// Add ATC-dialog to the command list
- globals->get_commands()->addCommand("ATC-dialog", doATCDialog);
+ globals->get_commands()->addCommand("ATC-dialog", FGATCDialogNew::popup );
// Add ATC-freq-search to the command list
//globals->get_commands()->addCommand("ATC-freq-search", do_ATC_freq_search);
typedef vector<string> StringVec;
typedef vector<string>:: iterator StringVecIterator;
-static bool doATCDialog(const SGPropertyNode* arg);
class FGATCDialogNew {
private:
NewGUI *_gui;
bool dialogVisible;
StringVec commands;
+
+ static FGATCDialogNew *_instance;
public:
FGATCDialogNew();
void PopupDialog();
void addEntry(int, string);
void removeEntry(int);
+
+ static bool popup( const SGPropertyNode * ) {
+ instance()->PopupDialog();
+ return true;
+ }
+
+ inline static FGATCDialogNew * instance() {
+ if( _instance != NULL ) return _instance;
+ _instance = new FGATCDialogNew();
+ _instance->init();
+ return _instance;
+ }
};
-extern FGATCDialogNew *currentATCDialog;
#endif // _ATC_DIALOG_HXX_
\ No newline at end of file
}
}
} else {
- FGATCManager *atc = (FGATCManager*) globals->get_subsystem("atc");
- atc->getATCDialog()->addEntry(1, text);
-
+ FGATCDialogNew::instance()->addEntry(1, text);
}
}
trans_num->setIntValue(-1);
// PopupCallback(n);
//cerr << "Selected transmission message " << n << endl;
- FGATCManager *atc = (FGATCManager*) globals->get_subsystem("atc");
- atc->getATCDialog()->removeEntry(1);
+ FGATCDialogNew::instance()->removeEntry(1);
} else {
//cerr << "creading message for " << i->getAircraft()->getCallSign() << endl;
transmit(&(*i), msgId, msgDir, false);
// PopupCallback(n);
//cerr << "Selected transmission message " << n << endl;
FGATCManager *atc = (FGATCManager*) globals->get_subsystem("atc");
- atc->getATCDialog()->removeEntry(1);
+ FGATCDialogNew::instance()->removeEntry(1);
} else {
//cerr << "creating message for " << i->getAircraft()->getCallSign() << endl;
transmit(&(*i), msgId, msgDir, false);