From be274df23bb2eab0845b0f1a72942dbbb44b01a7 Mon Sep 17 00:00:00 2001 From: daveluff Date: Fri, 5 Sep 2003 10:23:20 +0000 Subject: [PATCH] Guard against update(...) getting called before init(...) --- src/ATC/AIMgr.cxx | 8 ++++++++ src/ATC/AIMgr.hxx | 2 ++ src/ATC/ATCmgr.cxx | 13 +++++++++++-- src/ATC/ATCmgr.hxx | 2 ++ 4 files changed, 23 insertions(+), 2 deletions(-) diff --git a/src/ATC/AIMgr.cxx b/src/ATC/AIMgr.cxx index 7223eb3d9..871feb8b4 100644 --- a/src/ATC/AIMgr.cxx +++ b/src/ATC/AIMgr.cxx @@ -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; diff --git a/src/ATC/AIMgr.hxx b/src/ATC/AIMgr.hxx index 01ef44455..a186d1307 100644 --- a/src/ATC/AIMgr.hxx +++ b/src/ATC/AIMgr.hxx @@ -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); diff --git a/src/ATC/ATCmgr.cxx b/src/ATC/ATCmgr.cxx index 302bc7d52..3a05d94b8 100644 --- a/src/ATC/ATCmgr.cxx +++ b/src/ATC/ATCmgr.cxx @@ -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. diff --git a/src/ATC/ATCmgr.hxx b/src/ATC/ATCmgr.hxx index e7f973499..6c1960fe2 100644 --- a/src/ATC/ATCmgr.hxx +++ b/src/ATC/ATCmgr.hxx @@ -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;