]> git.mxchange.org Git - flightgear.git/commitdiff
Guard against update(...) getting called before init(...)
authordaveluff <daveluff>
Fri, 5 Sep 2003 10:23:20 +0000 (10:23 +0000)
committerdaveluff <daveluff>
Fri, 5 Sep 2003 10:23:20 +0000 (10:23 +0000)
src/ATC/AIMgr.cxx
src/ATC/AIMgr.hxx
src/ATC/ATCmgr.cxx
src/ATC/ATCmgr.hxx

index 7223eb3d9b804627174d8160d62dec49699365fc..871feb8b461f58ed6ef5511c85470c2179c8d471 100644 (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;
 
index 01ef4445543531afd50e5afafca768f0ebea6fe9..a186d1307ccde231cdcf0f6307dad8a56abc2d10 100644 (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);
        
index 302bc7d5268b63cdfbc9b22522ed07bc86a4eadd..3a05d94b82ba2c56287a04061002a8930c73d7c8 100644 (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.
index e7f9734994891cda7a2c83e6765f2836fecedb3f..6c1960fe2271e71586c5a25d0864bb7cf1848b8a 100644 (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;