From d996d271215e0706a53dbe57b85256f7851a748a Mon Sep 17 00:00:00 2001 From: mfranz Date: Wed, 4 Apr 2007 19:05:59 +0000 Subject: [PATCH] - move fgInitTowerLocationListener() from fgInitPosition() to the init part of fgIdleFunction() in main.cxx. fgInitPosition() is called again at every reset, which would every time attach another listener. --- src/Main/fg_init.cxx | 17 +++++------------ src/Main/fg_init.hxx | 5 +++++ src/Main/main.cxx | 1 + 3 files changed, 11 insertions(+), 12 deletions(-) diff --git a/src/Main/fg_init.cxx b/src/Main/fg_init.cxx index fcdc6274f..0dba51ec4 100644 --- a/src/Main/fg_init.cxx +++ b/src/Main/fg_init.cxx @@ -693,7 +693,7 @@ struct FGTowerLocationListener : SGPropertyChangeListener { } }; -static void fgInitTowerLocationListener() { +void fgInitTowerLocationListener() { fgGetNode("/sim/tower/airport-id", true) ->addChangeListener( new FGTowerLocationListener() ); } @@ -1147,7 +1147,6 @@ bool fgInitPosition() { string fix = fgGetString("/sim/presets/fix"); fgSetDouble( "/orientation/heading-deg", hdg ); - fgInitTowerLocationListener(); if ( !set_pos && !apt.empty() && !rwy_no.empty() ) { // An airport + runway is requested @@ -1695,16 +1694,10 @@ bool fgInitSubsystems() { globals->add_subsystem("submodel_mgr", new FGSubmodelMgr); - // It's probably a good idea to initialize the top level traffic manager - // After the AI and ATC systems have been initialized properly. - // AI Traffic manager - globals->add_subsystem("Traffic Manager", new FGTrafficManager); - //FGTrafficManager *dispatcher = - // (FGTrafficManager*) globals->get_subsystem("Traffic Manager"); - //SGPath path = globals->get_fg_root(); - //path.append("/Traffic/fgtraffic.xml"); - //readXML(path.str(), - // *dispatcher); + // It's probably a good idea to initialize the top level traffic manager + // After the AI and ATC systems have been initialized properly. + // AI Traffic manager + globals->add_subsystem("Traffic Manager", new FGTrafficManager); //////////////////////////////////////////////////////////////////// diff --git a/src/Main/fg_init.hxx b/src/Main/fg_init.hxx index 73a8cd7eb..5bb589d9f 100644 --- a/src/Main/fg_init.hxx +++ b/src/Main/fg_init.hxx @@ -83,6 +83,11 @@ void fgReInitSubsystems(); // Set the initial position based on presets (or defaults) bool fgInitPosition(); + +// Listen to /sim/tower/airport-id and set tower view position accordingly +void fgInitTowerLocationListener(); + + // Initialize various time dependent systems (lighting, sun position, etc.) // returns a new instance of the SGTime class SGTime *fgInitTime(); diff --git a/src/Main/main.cxx b/src/Main/main.cxx index e90777a83..14ccc9efb 100644 --- a/src/Main/main.cxx +++ b/src/Main/main.cxx @@ -698,6 +698,7 @@ static void fgIdleFunction ( void ) { // based on the requested presets, calculate the true starting // lon, lat fgInitPosition(); + fgInitTowerLocationListener(); SGTime *t = fgInitTime(); globals->set_time_params( t );