Patch by Torsten Dryer: Remove the Ugly global dialog variable and remove rwy as a member variable from the AIFlightPlan class.
This commit is contained in:
parent
e00157d4e8
commit
152fec1cb6
10 changed files with 36 additions and 27 deletions
|
@ -71,7 +71,6 @@ bool FGAIWaypoint::contains(string target) {
|
|||
|
||||
FGAIFlightPlan::FGAIFlightPlan()
|
||||
{
|
||||
rwy = 0;
|
||||
sid = 0;
|
||||
repeat = false;
|
||||
distance_to_go = 0;
|
||||
|
|
|
@ -166,7 +166,6 @@ public:
|
|||
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;
|
||||
|
|
|
@ -226,7 +226,8 @@ bool FGAIFlightPlan::createTakeoffTaxi(FGAIAircraft * ac, bool firstFlight,
|
|||
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();
|
||||
|
@ -456,9 +457,8 @@ bool FGAIFlightPlan::createTakeOff(FGAIAircraft * ac, bool firstFlight,
|
|||
apt->getDynamics()->getActiveRunway(rwyClass, 1, activeRunway,
|
||||
heading);
|
||||
}
|
||||
rwy = apt->getRunwayByIdent(activeRunway);
|
||||
|
||||
|
||||
FGRunway * rwy = apt->getRunwayByIdent(activeRunway);
|
||||
assert( rwy != NULL );
|
||||
|
||||
double airportElev = apt->getElevation();
|
||||
|
||||
|
@ -513,7 +513,6 @@ bool FGAIFlightPlan::createClimb(FGAIAircraft * ac, bool firstFlight,
|
|||
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();
|
||||
|
@ -522,6 +521,9 @@ bool FGAIFlightPlan::createClimb(FGAIAircraft * ac, bool firstFlight,
|
|||
//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);
|
||||
|
@ -560,9 +562,8 @@ bool FGAIFlightPlan::createDescent(FGAIAircraft * ac, FGAirport * apt,
|
|||
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);
|
||||
|
@ -859,6 +860,9 @@ bool FGAIFlightPlan::createLanding(FGAIAircraft * ac, FGAirport * apt,
|
|||
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());
|
||||
|
|
|
@ -299,7 +299,8 @@ bool FGAIFlightPlan::createCruise(FGAIAircraft *ac, bool firstFlight, FGAirport
|
|||
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);
|
||||
|
|
|
@ -46,8 +46,6 @@ FGATCManager::~FGATCManager() {
|
|||
|
||||
void FGATCManager::init() {
|
||||
SGSubsystem::init();
|
||||
currentATCDialog = new FGATCDialogNew;
|
||||
currentATCDialog->init();
|
||||
|
||||
int leg = 0;
|
||||
|
||||
|
@ -219,7 +217,7 @@ void FGATCManager::update ( double time ) {
|
|||
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;
|
||||
|
||||
|
|
|
@ -50,7 +50,6 @@ private:
|
|||
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;
|
||||
|
||||
|
@ -60,7 +59,6 @@ public:
|
|||
void init();
|
||||
void addController(FGATCController *controller);
|
||||
void update(double time);
|
||||
FGATCDialogNew * getATCDialog() { return currentATCDialog; };
|
||||
};
|
||||
|
||||
#endif // _ATC_MRG_HXX_
|
|
@ -35,11 +35,12 @@
|
|||
|
||||
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()
|
||||
{
|
||||
|
@ -54,7 +55,7 @@ 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);
|
||||
|
||||
|
|
|
@ -43,13 +43,14 @@
|
|||
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();
|
||||
|
@ -61,8 +62,19 @@ public:
|
|||
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_
|
|
@ -731,9 +731,7 @@ void FGATCController::transmit(FGTrafficRecord * rec, AtcMsgId msgId,
|
|||
}
|
||||
}
|
||||
} else {
|
||||
FGATCManager *atc = (FGATCManager*) globals->get_subsystem("atc");
|
||||
atc->getATCDialog()->addEntry(1, text);
|
||||
|
||||
FGATCDialogNew::instance()->addEntry(1, text);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1151,8 +1149,7 @@ bool FGStartupController::checkTransmissionState(int st, time_t now, time_t star
|
|||
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);
|
||||
|
|
|
@ -679,7 +679,7 @@ bool FGGroundNetwork::checkTransmissionState(int minState, int maxState, Traffic
|
|||
// 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);
|
||||
|
|
Loading…
Add table
Reference in a new issue