From: ThorstenB Date: Sun, 18 Nov 2012 15:35:54 +0000 (+0100) Subject: Remove static property dependencies X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=a784443a2497022f28c4a7722e259be6a074f67e;p=flightgear.git Remove static property dependencies preventing us from wiping properties on reset/reinit/subsystem recreate. (more work required for "native_gui" and "ATC-Outputs" protocols) --- diff --git a/src/ATC/atc_mgr.cxx b/src/ATC/atc_mgr.cxx index 28639c910..67d53c9fc 100644 --- a/src/ATC/atc_mgr.cxx +++ b/src/ATC/atc_mgr.cxx @@ -48,6 +48,8 @@ void FGATCManager::init() { int leg = 0; + trans_num = globals->get_props()->getNode("/sim/atc/transmission-num", true); + // find a reasonable controller for our user's aircraft.. // Let's start by working out the following three scenarios: // Starting on ground at a parking position @@ -259,8 +261,7 @@ void FGATCManager::update ( double time ) { //string airport = fgGetString("/sim/presets/airport-id"); //FGAirport *apt = FGAirport::findByIdent(airport); // AT this stage we should update the flightplan, so that waypoint incrementing is conducted as well as leg loading. - static SGPropertyNode_ptr trans_num = globals->get_props()->getNode("/sim/atc/transmission-num", true); - int n = trans_num->getIntValue(); + int n = trans_num->getIntValue(); if (n == 1) { //cerr << "Toggling ground network visibility " << networkVisible << endl; networkVisible = !networkVisible; diff --git a/src/ATC/atc_mgr.hxx b/src/ATC/atc_mgr.hxx index 0d9efa730..f169e3415 100644 --- a/src/ATC/atc_mgr.hxx +++ b/src/ATC/atc_mgr.hxx @@ -52,6 +52,7 @@ private: FGATCController *controller, *prevController; // The ATC controller that is responsible for the user's aircraft. bool networkVisible; bool initSucceeded; + SGPropertyNode_ptr trans_num; public: FGATCManager(); @@ -61,4 +62,4 @@ public: void update(double time); }; -#endif // _ATC_MRG_HXX_ \ No newline at end of file +#endif // _ATC_MRG_HXX_ diff --git a/src/ATC/atcdialog.cxx b/src/ATC/atcdialog.cxx index 98a8e70cb..13b93fb7b 100644 --- a/src/ATC/atcdialog.cxx +++ b/src/ATC/atcdialog.cxx @@ -286,14 +286,4 @@ void FGATCDialogNew::update(double dt) { } else { _gui->showDialog(dialog_name); } - //dialogVisible = !dialogVisible; - return; - /* - static SGPropertyNode_ptr trans_num = globals->get_props()->getNode("/sim/atc/transmission-num", true); - int n = trans_num->getIntValue(); - if (n >= 0) { - trans_num->setIntValue(-1); - // PopupCallback(n); - cerr << "Selected transmission message" << n << endl; - } */ } diff --git a/src/ATC/trafficcontrol.cxx b/src/ATC/trafficcontrol.cxx index 7f1596a00..ecf4d1792 100644 --- a/src/ATC/trafficcontrol.cxx +++ b/src/ATC/trafficcontrol.cxx @@ -1190,7 +1190,7 @@ bool FGStartupController::checkTransmissionState(int st, time_t now, time_t star if ((msgDir == ATC_AIR_TO_GROUND) && isUserAircraft(i->getAircraft())) { //cerr << "Checking state " << st << " for " << i->getAircraft()->getCallSign() << endl; - static SGPropertyNode_ptr trans_num = globals->get_props()->getNode("/sim/atc/transmission-num", true); + SGPropertyNode_ptr trans_num = globals->get_props()->getNode("/sim/atc/transmission-num", true); int n = trans_num->getIntValue(); if (n == 0) { trans_num->setIntValue(-1); diff --git a/src/Airports/groundnetwork.cxx b/src/Airports/groundnetwork.cxx index fe4d2e75b..62d229f68 100644 --- a/src/Airports/groundnetwork.cxx +++ b/src/Airports/groundnetwork.cxx @@ -567,7 +567,7 @@ bool FGGroundNetwork::checkTransmissionState(int minState, int maxState, Traffic if ((state >= minState) && (state <= maxState) && available) { if ((msgDir == ATC_AIR_TO_GROUND) && isUserAircraft(i->getAircraft())) { //cerr << "Checking state " << state << " for " << i->getAircraft()->getCallSign() << endl; - static SGPropertyNode_ptr trans_num = globals->get_props()->getNode("/sim/atc/transmission-num", true); + SGPropertyNode_ptr trans_num = globals->get_props()->getNode("/sim/atc/transmission-num", true); int n = trans_num->getIntValue(); if (n == 0) { trans_num->setIntValue(-1); diff --git a/src/FDM/JSBSim/JSBSim.cxx b/src/FDM/JSBSim/JSBSim.cxx index d67e57194..95c282bef 100644 --- a/src/FDM/JSBSim/JSBSim.cxx +++ b/src/FDM/JSBSim/JSBSim.cxx @@ -328,6 +328,7 @@ FGJSBsim::FGJSBsim( double dt ) ab_brake_left_pct = fgGetNode("/autopilot/autobrake/brake-left-output", true); ab_brake_right_pct = fgGetNode("/autopilot/autobrake/brake-right-output", true); + altitude = fgGetNode("/position/altitude-ft"); temperature = fgGetNode("/environment/temperature-degc",true); pressure = fgGetNode("/environment/pressure-inhg",true); pressureSL = fgGetNode("/environment/pressure-sea-level-inhg",true); @@ -1006,7 +1007,6 @@ bool FGJSBsim::ToggleDataLogging(bool state) //Positions void FGJSBsim::set_Latitude(double lat) { - static SGConstPropertyNode_ptr altitude = fgGetNode("/position/altitude-ft"); double alt = altitude->getDoubleValue(); double sea_level_radius_meters, lat_geoc; diff --git a/src/FDM/JSBSim/JSBSim.hxx b/src/FDM/JSBSim/JSBSim.hxx index d6ba37430..8471ba1b4 100644 --- a/src/FDM/JSBSim/JSBSim.hxx +++ b/src/FDM/JSBSim/JSBSim.hxx @@ -271,6 +271,7 @@ private: SGPropertyNode_ptr wing_fold_pos_pct; SGPropertyNode_ptr tailhook_pos_pct; + SGConstPropertyNode_ptr altitude; SGPropertyNode_ptr temperature; SGPropertyNode_ptr pressure; SGPropertyNode_ptr pressureSL; diff --git a/src/FDM/LaRCsim/LaRCsim.cxx b/src/FDM/LaRCsim/LaRCsim.cxx index 60f54a146..e1bbb1127 100644 --- a/src/FDM/LaRCsim/LaRCsim.cxx +++ b/src/FDM/LaRCsim/LaRCsim.cxx @@ -166,7 +166,7 @@ void FGLaRCsim::update( double dt ) { fgSetDouble("/engines/engine/running", eng.getRunningFlag()); fgSetDouble("/engines/engine/cranking", eng.getCrankingFlag()); - static const SGPropertyNode *fuel_freeze + const SGPropertyNode *fuel_freeze = fgGetNode("/sim/freeze/fuel"); if ( ! fuel_freeze->getBoolValue() ) { @@ -237,7 +237,7 @@ void FGLaRCsim::update( double dt ) { fgSetDouble("/engines/engine/running", eng.getRunningFlag()); fgSetDouble("/engines/engine/cranking", eng.getCrankingFlag()); - static const SGPropertyNode *fuel_freeze + const SGPropertyNode *fuel_freeze = fgGetNode("/sim/freeze/fuel"); if ( ! fuel_freeze->getBoolValue() ) { diff --git a/src/FDM/UIUCModel/uiuc_gear.cpp b/src/FDM/UIUCModel/uiuc_gear.cpp index 31a87d0b9..5cef35357 100644 --- a/src/FDM/UIUCModel/uiuc_gear.cpp +++ b/src/FDM/UIUCModel/uiuc_gear.cpp @@ -274,14 +274,7 @@ void uiuc_gear() clear3(f_wheel_local_v); reaction_normal_force=0; -#if 0 - static const SGPropertyNode * gear_wow - = fgGetNode("/gear/gear[0]/wow", false); - static const SGPropertyNode * gear_wow1 - = fgGetNode("/gear/gear[1]/wow", false); - static const SGPropertyNode * gear_wow2 - = fgGetNode("/gear/gear[2]/wow", false); -#endif + fgSetBool("/gear/gear[0]/wow", false); fgSetBool("/gear/gear[1]/wow", false); fgSetBool("/gear/gear[2]/wow", false); diff --git a/src/GUI/gui_funcs.cxx b/src/GUI/gui_funcs.cxx index 1da13da29..fa4488c42 100644 --- a/src/GUI/gui_funcs.cxx +++ b/src/GUI/gui_funcs.cxx @@ -230,12 +230,11 @@ void fgHiResDump() char *filename = new char [24]; static int count = 1; - static const SGPropertyNode *master_freeze - = fgGetNode("/sim/freeze/master"); + SGPropertyNode *master_freeze = fgGetNode("/sim/freeze/master"); bool freeze = master_freeze->getBoolValue(); if ( !freeze ) { - fgSetBool("/sim/freeze/master", true); + master_freeze->setBoolValue(true); } fgSetBool("/sim/menubar/visibility", false); @@ -416,7 +415,7 @@ void fgHiResDump() fgSetBool("/sim/menubar/visibility", menu_status); if ( !freeze ) { - fgSetBool("/sim/freeze/master", false); + master_freeze->setBoolValue(false); } } #endif // #if defined( TR_HIRES_SNAP) @@ -558,11 +557,11 @@ bool fgDumpSnapShot () return GUISnapShotOperation::start(); #else // obsolete code => remove when new code is stable - static SGConstPropertyNode_ptr master_freeze = fgGetNode("/sim/freeze/master"); + SGPropertyNode_ptr master_freeze = fgGetNode("/sim/freeze/master"); bool freeze = master_freeze->getBoolValue(); if ( !freeze ) { - fgSetBool("/sim/freeze/master", true); + master_freeze->setBoolValue(true); } int mouse = fgGetMouseCursor(); @@ -614,7 +613,7 @@ bool fgDumpSnapShot () fgSetMouseCursor(mouse); if ( !freeze ) { - fgSetBool("/sim/freeze/master", false); + master_freeze->setBoolValue(false); } return result; #endif @@ -627,12 +626,11 @@ void fgDumpSceneGraph() string message; static int count = 1; - static const SGPropertyNode *master_freeze - = fgGetNode("/sim/freeze/master"); + SGPropertyNode *master_freeze = fgGetNode("/sim/freeze/master"); bool freeze = master_freeze->getBoolValue(); if ( !freeze ) { - fgSetBool("/sim/freeze/master", true); + master_freeze->setBoolValue(true); } while (count < 1000) { @@ -658,7 +656,7 @@ void fgDumpSceneGraph() delete [] filename; if ( !freeze ) { - fgSetBool("/sim/freeze/master", false); + master_freeze->setBoolValue(false); } } @@ -670,12 +668,11 @@ void fgDumpTerrainBranch() string message; static int count = 1; - static const SGPropertyNode *master_freeze - = fgGetNode("/sim/freeze/master"); + SGPropertyNode *master_freeze = fgGetNode("/sim/freeze/master"); bool freeze = master_freeze->getBoolValue(); if ( !freeze ) { - fgSetBool("/sim/freeze/master", true); + master_freeze->setBoolValue(true); } while (count < 1000) { @@ -701,26 +698,22 @@ void fgDumpTerrainBranch() delete [] filename; if ( !freeze ) { - fgSetBool("/sim/freeze/master", false); + master_freeze->setBoolValue(false); } } void fgPrintVisibleSceneInfoCommand() { - static const SGPropertyNode *master_freeze - = fgGetNode("/sim/freeze/master"); + SGPropertyNode *master_freeze = fgGetNode("/sim/freeze/master"); bool freeze = master_freeze->getBoolValue(); if ( !freeze ) { - fgSetBool("/sim/freeze/master", true); + master_freeze->setBoolValue(true); } flightgear::printVisibleSceneInfo(globals->get_renderer()); if ( !freeze ) { - fgSetBool("/sim/freeze/master", false); + master_freeze->setBoolValue(false); } } - - - diff --git a/src/Instrumentation/heading_indicator_dg.cxx b/src/Instrumentation/heading_indicator_dg.cxx index 8966c0f3d..0c5fdf879 100644 --- a/src/Instrumentation/heading_indicator_dg.cxx +++ b/src/Instrumentation/heading_indicator_dg.cxx @@ -184,7 +184,7 @@ HeadingIndicatorDG::update (double dt) // calculate the difference between the indicated heading // and the selected heading for use with an autopilot - static SGPropertyNode *bnode + SGPropertyNode *bnode = fgGetNode( "/autopilot/settings/heading-bug-deg", false ); if ( bnode ) { double diff = bnode->getDoubleValue() - heading; diff --git a/src/Instrumentation/heading_indicator_fg.cxx b/src/Instrumentation/heading_indicator_fg.cxx index fc7bff442..32332a3e1 100644 --- a/src/Instrumentation/heading_indicator_fg.cxx +++ b/src/Instrumentation/heading_indicator_fg.cxx @@ -160,7 +160,7 @@ HeadingIndicatorFG::update (double dt) // calculate the difference between the indicated heading // and the selected heading for use with an autopilot - static SGPropertyNode *bnode + SGPropertyNode *bnode = fgGetNode( "/autopilot/settings/heading-bug-deg", false ); double diff = 0; if ( bnode ){ diff --git a/src/Instrumentation/mrg.cxx b/src/Instrumentation/mrg.cxx index 1eb1f2394..8a77fc175 100644 --- a/src/Instrumentation/mrg.cxx +++ b/src/Instrumentation/mrg.cxx @@ -233,7 +233,7 @@ MasterReferenceGyro::update (double dt) indicated_hdg_rate = _last_yaw_rate; // calculate the difference between the indicated heading // and the selected heading for use with an autopilot - static SGPropertyNode *bnode + SGPropertyNode *bnode = fgGetNode( "/autopilot/settings/heading-bug-deg", false ); if ( bnode ) { diff --git a/src/Main/fg_commands.cxx b/src/Main/fg_commands.cxx index f32c29b57..746664f26 100644 --- a/src/Main/fg_commands.cxx +++ b/src/Main/fg_commands.cxx @@ -465,18 +465,17 @@ do_hires_screen_capture (const SGPropertyNode * arg) static bool do_tile_cache_reload (const SGPropertyNode * arg) { - static const SGPropertyNode *master_freeze - = fgGetNode("/sim/freeze/master"); + SGPropertyNode *master_freeze = fgGetNode("/sim/freeze/master"); bool freeze = master_freeze->getBoolValue(); SG_LOG(SG_INPUT, SG_INFO, "ReIniting TileCache"); if ( !freeze ) { - fgSetBool("/sim/freeze/master", true); + master_freeze->setBoolValue(true); } globals->get_subsystem("tile-manager")->reinit(); if ( !freeze ) { - fgSetBool("/sim/freeze/master", false); + master_freeze->setBoolValue(false); } return true; } diff --git a/src/Main/fg_init.cxx b/src/Main/fg_init.cxx index f7c591d39..4abac9a31 100644 --- a/src/Main/fg_init.cxx +++ b/src/Main/fg_init.cxx @@ -793,15 +793,14 @@ void fgPostInitSubsystems() // Reset: this is what the 'reset' command (and hence, GUI) is attached to void fgReInitSubsystems() { - static const SGPropertyNode *master_freeze - = fgGetNode("/sim/freeze/master"); + SGPropertyNode *master_freeze = fgGetNode("/sim/freeze/master"); SG_LOG( SG_GENERAL, SG_INFO, "fgReInitSubsystems()"); // setup state to begin re-init bool freeze = master_freeze->getBoolValue(); if ( !freeze ) { - fgSetBool("/sim/freeze/master", true); + master_freeze->setBoolValue(true); } fgSetBool("/sim/signals/reinit", true); @@ -846,7 +845,7 @@ void fgReInitSubsystems() // setup state to end re-init fgSetBool("/sim/signals/reinit", false); if ( !freeze ) { - fgSetBool("/sim/freeze/master", false); + master_freeze->setBoolValue(false); } fgSetBool("/sim/sceneryloaded",false); } diff --git a/src/Main/fg_props.cxx b/src/Main/fg_props.cxx index 8f3036776..d8bda0f08 100644 --- a/src/Main/fg_props.cxx +++ b/src/Main/fg_props.cxx @@ -376,14 +376,19 @@ setWindingCCW (bool state) glFrontFace ( GL_CW ); } -static const char * -getLongitudeString () +//////////////////////////////////////////////////////////////////////// +// Tie the properties. +//////////////////////////////////////////////////////////////////////// +SGConstPropertyNode_ptr FGProperties::_longDeg; +SGConstPropertyNode_ptr FGProperties::_latDeg; +SGConstPropertyNode_ptr FGProperties::_lonLatformat; + +const char * +FGProperties::getLongitudeString () { - static SGConstPropertyNode_ptr n = fgGetNode("/position/longitude-deg", true); - static SGConstPropertyNode_ptr f = fgGetNode("/sim/lon-lat-format", true); static char buf[32]; - double d = n->getDoubleValue(); - int format = f->getIntValue(); + double d = _longDeg->getDoubleValue(); + int format = _lonLatformat->getIntValue(); char c = d < 0.0 ? 'W' : 'E'; if (format == 0) { @@ -411,14 +416,12 @@ getLongitudeString () return buf; } -static const char * -getLatitudeString () +const char * +FGProperties::getLatitudeString () { - static SGConstPropertyNode_ptr n = fgGetNode("/position/latitude-deg", true); - static SGConstPropertyNode_ptr f = fgGetNode("/sim/lon-lat-format", true); static char buf[32]; - double d = n->getDoubleValue(); - int format = f->getIntValue(); + double d = _latDeg->getDoubleValue(); + int format = _lonLatformat->getIntValue(); char c = d < 0.0 ? 'S' : 'N'; if (format == 0) { @@ -443,9 +446,6 @@ getLatitudeString () -//////////////////////////////////////////////////////////////////////// -// Tie the properties. -//////////////////////////////////////////////////////////////////////// FGProperties::FGProperties () { @@ -463,6 +463,31 @@ FGProperties::init () void FGProperties::bind () { + _longDeg = fgGetNode("/position/longitude-deg", true); + _latDeg = fgGetNode("/position/latitude-deg", true); + _lonLatformat = fgGetNode("/sim/lon-lat-format", true); + + _offset = fgGetNode("/sim/time/local-offset", true); + + // utc date/time + _uyear = fgGetNode("/sim/time/utc/year", true); + _umonth = fgGetNode("/sim/time/utc/month", true); + _uday = fgGetNode("/sim/time/utc/day", true); + _uhour = fgGetNode("/sim/time/utc/hour", true); + _umin = fgGetNode("/sim/time/utc/minute", true); + _usec = fgGetNode("/sim/time/utc/second", true); + _uwday = fgGetNode("/sim/time/utc/weekday", true); + _udsec = fgGetNode("/sim/time/utc/day-seconds", true); + + // real local date/time + _ryear = fgGetNode("/sim/time/real/year", true); + _rmonth = fgGetNode("/sim/time/real/month", true); + _rday = fgGetNode("/sim/time/real/day", true); + _rhour = fgGetNode("/sim/time/real/hour", true); + _rmin = fgGetNode("/sim/time/real/minute", true); + _rsec = fgGetNode("/sim/time/real/second", true); + _rwday = fgGetNode("/sim/time/real/weekday", true); + _tiedProperties.setRoot(globals->get_props()); // Simulation @@ -491,54 +516,39 @@ void FGProperties::unbind () { _tiedProperties.Untie(); + + // drop static references to properties + _longDeg = 0; + _latDeg = 0; + _lonLatformat = 0; } void FGProperties::update (double dt) { - static SGPropertyNode_ptr offset = fgGetNode("/sim/time/local-offset", true); - offset->setIntValue(globals->get_time_params()->get_local_offset()); + _offset->setIntValue(globals->get_time_params()->get_local_offset()); // utc date/time - static SGPropertyNode_ptr uyear = fgGetNode("/sim/time/utc/year", true); - static SGPropertyNode_ptr umonth = fgGetNode("/sim/time/utc/month", true); - static SGPropertyNode_ptr uday = fgGetNode("/sim/time/utc/day", true); - static SGPropertyNode_ptr uhour = fgGetNode("/sim/time/utc/hour", true); - static SGPropertyNode_ptr umin = fgGetNode("/sim/time/utc/minute", true); - static SGPropertyNode_ptr usec = fgGetNode("/sim/time/utc/second", true); - static SGPropertyNode_ptr uwday = fgGetNode("/sim/time/utc/weekday", true); - static SGPropertyNode_ptr udsec = fgGetNode("/sim/time/utc/day-seconds", true); - struct tm *u = globals->get_time_params()->getGmt(); - uyear->setIntValue(u->tm_year + 1900); - umonth->setIntValue(u->tm_mon + 1); - uday->setIntValue(u->tm_mday); - uhour->setIntValue(u->tm_hour); - umin->setIntValue(u->tm_min); - usec->setIntValue(u->tm_sec); - uwday->setIntValue(u->tm_wday); - - udsec->setIntValue(u->tm_hour * 3600 + u->tm_min * 60 + u->tm_sec); - + _uyear->setIntValue(u->tm_year + 1900); + _umonth->setIntValue(u->tm_mon + 1); + _uday->setIntValue(u->tm_mday); + _uhour->setIntValue(u->tm_hour); + _umin->setIntValue(u->tm_min); + _usec->setIntValue(u->tm_sec); + _uwday->setIntValue(u->tm_wday); + _udsec->setIntValue(u->tm_hour * 3600 + u->tm_min * 60 + u->tm_sec); // real local date/time - static SGPropertyNode_ptr ryear = fgGetNode("/sim/time/real/year", true); - static SGPropertyNode_ptr rmonth = fgGetNode("/sim/time/real/month", true); - static SGPropertyNode_ptr rday = fgGetNode("/sim/time/real/day", true); - static SGPropertyNode_ptr rhour = fgGetNode("/sim/time/real/hour", true); - static SGPropertyNode_ptr rmin = fgGetNode("/sim/time/real/minute", true); - static SGPropertyNode_ptr rsec = fgGetNode("/sim/time/real/second", true); - static SGPropertyNode_ptr rwday = fgGetNode("/sim/time/real/weekday", true); - time_t real = time(0); struct tm *r = localtime(&real); - ryear->setIntValue(r->tm_year + 1900); - rmonth->setIntValue(r->tm_mon + 1); - rday->setIntValue(r->tm_mday); - rhour->setIntValue(r->tm_hour); - rmin->setIntValue(r->tm_min); - rsec->setIntValue(r->tm_sec); - rwday->setIntValue(r->tm_wday); + _ryear->setIntValue(r->tm_year + 1900); + _rmonth->setIntValue(r->tm_mon + 1); + _rday->setIntValue(r->tm_mday); + _rhour->setIntValue(r->tm_hour); + _rmin->setIntValue(r->tm_min); + _rsec->setIntValue(r->tm_sec); + _rwday->setIntValue(r->tm_wday); } diff --git a/src/Main/fg_props.hxx b/src/Main/fg_props.hxx index 023d4dbbf..81f4baffb 100644 --- a/src/Main/fg_props.hxx +++ b/src/Main/fg_props.hxx @@ -30,6 +30,15 @@ public: private: simgear::TiedPropertyList _tiedProperties; + + static const char* getLatitudeString (); + static const char* getLongitudeString (); + + static SGConstPropertyNode_ptr _longDeg, _latDeg, _lonLatformat; + + SGPropertyNode_ptr _offset; + SGPropertyNode_ptr _uyear, _umonth, _uday, _uhour, _umin, _usec, _uwday, _udsec; + SGPropertyNode_ptr _ryear, _rmonth, _rday, _rhour, _rmin, _rsec, _rwday, _rdsec; }; diff --git a/src/Main/main.cxx b/src/Main/main.cxx index 5455b3106..f8b0fe0aa 100644 --- a/src/Main/main.cxx +++ b/src/Main/main.cxx @@ -75,13 +75,12 @@ using std::vector; // is initialized. extern int _bootstrap_OSInit; +static SGPropertyNode_ptr frame_signal; + // What should we do when we have nothing else to do? Let's get ready // for the next move and update the display? static void fgMainLoop( void ) { - static SGPropertyNode_ptr frame_signal - = fgGetNode("/sim/signals/frame", true); - frame_signal->fireValueChanged(); SG_LOG( SG_GENERAL, SG_DEBUG, "Running Main Loop"); @@ -264,6 +263,8 @@ static void fgIdleFunction ( void ) { // We've finished all our initialization steps, from now on we // run the main loop. fgSetBool("sim/sceneryloaded", false); + // stash current frame signal property + frame_signal = fgGetNode("/sim/signals/frame", true); fgRegisterIdleHandler( fgMainLoop ); } } diff --git a/src/Main/util.cxx b/src/Main/util.cxx index 9b5b3da8b..8efbb93fa 100644 --- a/src/Main/util.cxx +++ b/src/Main/util.cxx @@ -129,16 +129,15 @@ fgUnescape (const char *s) // or an empty string otherwise. const char *fgValidatePath (const char *str, bool write) { - static SGPropertyNode_ptr r, w; - if (!r) { - r = fgGetNode("/sim/paths/validate/read", true); - r->setAttribute(SGPropertyNode::READ, true); - r->setAttribute(SGPropertyNode::WRITE, true); - - w = fgGetNode("/sim/paths/validate/write", true); - w->setAttribute(SGPropertyNode::READ, true); - w->setAttribute(SGPropertyNode::WRITE, true); - } + SGPropertyNode_ptr r, w; + r = fgGetNode("/sim/paths/validate/read", true); + r->setAttribute(SGPropertyNode::READ, true); + r->setAttribute(SGPropertyNode::WRITE, true); + + w = fgGetNode("/sim/paths/validate/write", true); + w->setAttribute(SGPropertyNode::READ, true); + w->setAttribute(SGPropertyNode::WRITE, true); + SGPropertyNode *prop = write ? w : r; prop->setStringValue(str); const char *result = prop->getStringValue(); diff --git a/src/Network/ATC-Outputs.cxx b/src/Network/ATC-Outputs.cxx index 5930edb65..becc423f1 100644 --- a/src/Network/ATC-Outputs.cxx +++ b/src/Network/ATC-Outputs.cxx @@ -20,6 +20,7 @@ // // $Id$ +// TODO FIXME Module still contains lots of "static SGPropertyNode"s below. #ifdef HAVE_CONFIG_H # include diff --git a/src/Network/atlas.cxx b/src/Network/atlas.cxx index c48c3add7..29c4980fb 100644 --- a/src/Network/atlas.cxx +++ b/src/Network/atlas.cxx @@ -40,8 +40,15 @@ #include "atlas.hxx" -FGAtlas::FGAtlas() { - fdm = new FlightProperties; +FGAtlas::FGAtlas() : + length(0), + fdm(new FlightProperties) +{ + _adf_freq = fgGetNode("/instrumentation/adf/frequencies/selected-khz", true); + _nav1_freq = fgGetNode("/instrumentation/nav/frequencies/selected-mhz", true); + _nav1_sel_radial = fgGetNode("/instrumentation/nav/radials/selected-deg", true); + _nav2_freq = fgGetNode("/instrumentation/nav[1]/frequencies/selected-mhz", true); + _nav2_sel_radial = fgGetNode("/instrumentation/nav[1]/radials/selected-deg", true); } FGAtlas::~FGAtlas() { @@ -71,18 +78,6 @@ static char calc_atlas_cksum(char *sentence) { // generate Atlas message bool FGAtlas::gen_message() { // cout << "generating atlas message" << endl; - - static SGPropertyNode *adf_freq - = fgGetNode("/instrumentation/adf/frequencies/selected-khz", true); - static SGPropertyNode *nav1_freq - = fgGetNode("/instrumentation/nav/frequencies/selected-mhz", true); - static SGPropertyNode *nav1_sel_radial - = fgGetNode("/instrumentation/nav/radials/selected-deg", true); - static SGPropertyNode *nav2_freq - = fgGetNode("/instrumentation/nav[1]/frequencies/selected-mhz", true); - static SGPropertyNode *nav2_sel_radial - = fgGetNode("/instrumentation/nav[1]/radials/selected-deg", true); - char rmc[256], gga[256], patla[256]; char rmc_sum[10], gga_sum[10], patla_sum[10]; char dir; @@ -146,11 +141,11 @@ bool FGAtlas::gen_message() { sprintf( gga_sum, "%02X", calc_atlas_cksum(gga) ); sprintf( patla, "PATLA,%.2f,%.1f,%.2f,%.1f,%.0f", - nav1_freq->getDoubleValue(), - nav1_sel_radial->getDoubleValue(), - nav2_freq->getDoubleValue(), - nav2_sel_radial->getDoubleValue(), - adf_freq->getDoubleValue() ); + _nav1_freq->getDoubleValue(), + _nav1_sel_radial->getDoubleValue(), + _nav2_freq->getDoubleValue(), + _nav2_sel_radial->getDoubleValue(), + _adf_freq->getDoubleValue() ); sprintf( patla_sum, "%02X", calc_atlas_cksum(patla) ); SG_LOG( SG_IO, SG_DEBUG, rmc ); diff --git a/src/Network/atlas.hxx b/src/Network/atlas.hxx index f73a14d7d..df211284f 100644 --- a/src/Network/atlas.hxx +++ b/src/Network/atlas.hxx @@ -30,6 +30,7 @@ #include #include "protocol.hxx" +#include class FlightProperties; @@ -38,7 +39,8 @@ class FGAtlas : public FGProtocol { char buf[ FG_MAX_MSG_SIZE ]; int length; FlightProperties* fdm; - + SGPropertyNode_ptr _adf_freq, _nav1_freq,_nav1_sel_radial, _nav2_freq, _nav2_sel_radial; + public: FGAtlas(); diff --git a/src/Network/native_gui.cxx b/src/Network/native_gui.cxx index 720b08dba..e78ac47ff 100644 --- a/src/Network/native_gui.cxx +++ b/src/Network/native_gui.cxx @@ -20,6 +20,7 @@ // // $Id$ +// TODO FIXME Module still contains lots of "static SGPropertyNode"s below. #ifdef HAVE_CONFIG_H # include diff --git a/src/Time/light.cxx b/src/Time/light.cxx index dc176ae6a..5ccbcff27 100644 --- a/src/Time/light.cxx +++ b/src/Time/light.cxx @@ -151,6 +151,7 @@ void FGLight::bind () { _sunAngleRad = prop->getNode("/sim/time/sun-angle-rad", true); _sunAngleRad->setDoubleValue(_sun_angle); + _humidity = fgGetNode("/environment/relative-humidity", true); // Read Only tie(prop,"/rendering/scene/ambient/red", SGRawValuePointer(&_scene_ambient[0])); @@ -210,8 +211,7 @@ void FGLight::update_sky_color () { // calculate lighting parameters based on sun's relative angle to // local up - static SGConstPropertyNode_ptr humidity = fgGetNode("/environment/relative-humidity"); - float av = humidity->getFloatValue() * 45; + float av = _humidity->getFloatValue() * 45; float visibility_log = log(av)/11.0; float visibility_inv = (45000.0 - av)/45000.0; diff --git a/src/Time/light.hxx b/src/Time/light.hxx index dd68c4741..a1f1c8d79 100644 --- a/src/Time/light.hxx +++ b/src/Time/light.hxx @@ -117,6 +117,8 @@ private: SGPropertyNode_ptr _sunAngleRad; + SGPropertyNode_ptr _humidity; + simgear::TiedPropertyList _tiedProperties; /** diff --git a/src/Viewer/FGEventHandler.cxx b/src/Viewer/FGEventHandler.cxx index 9951c0027..1174adc6d 100644 --- a/src/Viewer/FGEventHandler.cxx +++ b/src/Viewer/FGEventHandler.cxx @@ -83,6 +83,9 @@ FGEventHandler::FGEventHandler() : for (int i = 0; i < 128; i++) release_keys[i] = i; + + _display = fgGetNode("/sim/rendering/on-screen-statistics", true); + _print = fgGetNode("/sim/rendering/print-statistics", true); } namespace @@ -356,10 +359,7 @@ void FGEventHandler::handleKey(const osgGA::GUIEventAdapter& ea, int& key, void FGEventHandler::handleStats(osgGA::GUIActionAdapter& us) { - static SGPropertyNode_ptr display = fgGetNode("/sim/rendering/on-screen-statistics", true); - static SGPropertyNode_ptr print = fgGetNode("/sim/rendering/print-statistics", true); - - int type = display->getIntValue() % osgViewer::StatsHandler::LAST; + int type = _display->getIntValue() % osgViewer::StatsHandler::LAST; if (type != statsType) { statsEvent->setKey(displayStatsKey); do { @@ -371,13 +371,13 @@ void FGEventHandler::handleStats(osgGA::GUIActionAdapter& us) } } while (statsType != type); - display->setIntValue(statsType); + _display->setIntValue(statsType); } - if (print->getBoolValue()) { + if (_print->getBoolValue()) { statsEvent->setKey(printStatsKey); statsHandler->handle(*statsEvent, us); - print->setBoolValue(false); + _print->setBoolValue(false); } } diff --git a/src/Viewer/FGEventHandler.hxx b/src/Viewer/FGEventHandler.hxx index 2e38c411c..59a25381a 100644 --- a/src/Viewer/FGEventHandler.hxx +++ b/src/Viewer/FGEventHandler.hxx @@ -120,6 +120,7 @@ protected: int release_keys[128]; void handleStats(osgGA::GUIActionAdapter& us); bool changeStatsCameraRenderOrder; + SGPropertyNode_ptr _display, _print; }; void eventToWindowCoords(const osgGA::GUIEventAdapter* ea, double& x, double& y); diff --git a/src/Viewer/renderer.cxx b/src/Viewer/renderer.cxx index 8745d4189..3f82a2052 100644 --- a/src/Viewer/renderer.cxx +++ b/src/Viewer/renderer.cxx @@ -409,7 +409,6 @@ FGRenderer::FGRenderer() : #ifdef FG_JPEG_SERVER jpgRenderFrame = updateRenderer; #endif - eventHandler = new FGEventHandler; _numCascades = 4; _cascadeFar[0] = 5.f; @@ -487,6 +486,8 @@ public: void FGRenderer::init( void ) { + eventHandler = new FGEventHandler(); + sgUserDataInit( globals->get_props() ); _classicalRenderer = !fgGetBool("/sim/rendering/rembrandt/enabled", false);