1
0
Fork 0

Guard against update(...) getting called before init(...)

This commit is contained in:
daveluff 2003-09-05 10:23:20 +00:00
parent 1520fd648e
commit be274df23b
4 changed files with 23 additions and 2 deletions

View file

@ -42,6 +42,7 @@ SG_USING_STD(cout);
FGAIMgr::FGAIMgr() {
ATC = globals->get_ATC_mgr();
initDone = false;
}
FGAIMgr::~FGAIMgr() {
@ -141,6 +142,8 @@ void FGAIMgr::init() {
// See if are in range at startup and activate if necessary
SearchByPos(10.0);
initDone = true;
}
void FGAIMgr::bind() {
@ -150,6 +153,11 @@ void FGAIMgr::unbind() {
}
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;

View file

@ -91,6 +91,8 @@ public:
private:
bool initDone; // Hack - guard against update getting called before init
// Remove a class from the ai_list and delete it from memory
//void RemoveFromList(const char* id, atc_type tp);

View file

@ -65,8 +65,10 @@ FGATCMgr::FGATCMgr() {
comm_type[1] = INVALID;
comm_atc_ptr[0] = NULL;
comm_atc_ptr[1] = NULL;
comm_valid[0] = false;
comm_valid[1] = false;
comm_valid[0] = false;
comm_valid[1] = false;
initDone = false;
}
FGATCMgr::~FGATCMgr() {
@ -130,9 +132,16 @@ void FGATCMgr::init() {
// DCL - testing
//current_atcdialog->add_entry( "EGNX", "Request vectoring for approach", "Request Vectors" );
//current_atcdialog->add_entry( "EGNX", "Mayday, Mayday", "Declare Emergency" );
initDone = true;
}
void FGATCMgr::update(double dt) {
if(!initDone) {
init();
SG_LOG(SG_ATC, SG_WARN, "Warning - ATCMgr::update(...) called before ATCMgr::init()");
}
//cout << "Entering update..." << endl;
//Traverse the list of active stations.
//Only update one class per update step to avoid the whole ATC system having to calculate between frames.

View file

@ -77,6 +77,8 @@ class FGATCMgr : public FGSubsystem
private:
bool initDone; // Hack - guard against update getting called before init
// A map of airport ID vs frequencies and ATC provision
typedef map < string, AirportATC* > airport_atc_map_type;
typedef airport_atc_map_type::iterator airport_atc_map_iterator;