From ce8ca7853cbac81c05e84a19f00cf79a2eb24aa9 Mon Sep 17 00:00:00 2001 From: James Turner Date: Wed, 24 Nov 2010 20:57:56 +0000 Subject: [PATCH 1/8] Fix bug #125 --- src/Main/fg_io.cxx | 27 +++++++++++++++------------ src/Main/fg_io.hxx | 3 +++ 2 files changed, 18 insertions(+), 12 deletions(-) diff --git a/src/Main/fg_io.cxx b/src/Main/fg_io.cxx index dda35d069..75ec5c978 100644 --- a/src/Main/fg_io.cxx +++ b/src/Main/fg_io.cxx @@ -306,6 +306,8 @@ FGIO::init() // SG_LOG( SG_IO, SG_INFO, "I/O Channel initialization, " << // globals->get_channel_options_list()->size() << " requests." ); + _realDeltaTime = fgGetNode("/sim/time/delta-realtime-sec"); + FGProtocol *p; // we could almost do this in a single step except pushing a valid @@ -339,30 +341,31 @@ FGIO::reinit() // process any IO channel work void -FGIO::update( double delta_time_sec ) +FGIO::update( double /* delta_time_sec */ ) { - // cout << "processing I/O channels" << endl; - // cout << " Elapsed time = " << delta_time_sec << endl; + // use wall-clock, not simulation, delta time, so that network + // protocols update when the simulation is paused + // see http://code.google.com/p/flightgear-bugs/issues/detail?id=125 + double delta_time_sec = _realDeltaTime->getDoubleValue(); ProtocolVec::iterator i = io_channels.begin(); ProtocolVec::iterator end = io_channels.end(); for (; i != end; ++i ) { - FGProtocol* p = *i; - - if ( p->is_enabled() ) { + FGProtocol* p = *i; + if (!p->is_enabled()) { + continue; + } + p->dec_count_down( delta_time_sec ); double dt = 1 / p->get_hz(); if ( p->get_count_down() < 0.33 * dt ) { p->process(); p->inc_count(); while ( p->get_count_down() < 0.33 * dt ) { - p->inc_count_down( dt ); + p->inc_count_down( dt ); } - // double ave = elapsed_time / p->get_count(); - // cout << " ave rate = " << ave << endl; - } - } - } + } // of channel processing + } // of io_channels iteration } void diff --git a/src/Main/fg_io.hxx b/src/Main/fg_io.hxx index 5637c5df5..d10e9c67b 100644 --- a/src/Main/fg_io.hxx +++ b/src/Main/fg_io.hxx @@ -27,6 +27,7 @@ #include #include +#include #include #include @@ -58,6 +59,8 @@ private: typedef std::vector< FGProtocol* > ProtocolVec; ProtocolVec io_channels; + + SGPropertyNode_ptr _realDeltaTime; }; From 793fee679eef2f9d6f1dc98103950dd386ab576e Mon Sep 17 00:00:00 2001 From: James Turner Date: Fri, 26 Nov 2010 02:10:41 +0000 Subject: [PATCH 2/8] Fix for bug 62, clean exit of terrasync on SIGTERM --- utils/TerraSync/terrasync.cxx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/utils/TerraSync/terrasync.cxx b/utils/TerraSync/terrasync.cxx index 0628e2aef..d48e43f77 100644 --- a/utils/TerraSync/terrasync.cxx +++ b/utils/TerraSync/terrasync.cxx @@ -279,7 +279,7 @@ int termination_triggering_signals[] = { #if defined(_MSC_VER) || defined(__MINGW32__) SIGINT, SIGILL, SIGFPE, SIGSEGV, SIGTERM, SIGBREAK, SIGABRT, #else - SIGHUP, SIGINT, SIGQUIT, SIGKILL, + SIGHUP, SIGINT, SIGQUIT, SIGKILL, SIGTERM, #endif 0}; // zero terminated From f33d26d51ce24468ddf0de42686c87f415b85669 Mon Sep 17 00:00:00 2001 From: Torsten Dreyer Date: Fri, 26 Nov 2010 16:14:43 +0100 Subject: [PATCH 3/8] Warning fix: unused variables --- src/Instrumentation/HUD/HUD_runway.cxx | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/Instrumentation/HUD/HUD_runway.cxx b/src/Instrumentation/HUD/HUD_runway.cxx index ae6ebba65..6f05a706a 100644 --- a/src/Instrumentation/HUD/HUD_runway.cxx +++ b/src/Instrumentation/HUD/HUD_runway.cxx @@ -78,12 +78,12 @@ void HUD::Runway::draw() float modelView[4][4], projMat[4][4]; bool anyLines; //Get the current view - FGViewer* curr_view = globals->get_viewmgr()->get_current_view(); - int curr_view_id = globals->get_viewmgr()->get_current(); - double gpo = curr_view->getGoalPitchOffset_deg(); - double gho = curr_view->getGoalHeadingOffset_deg(); - double po = curr_view->getPitchOffset_deg(); - double ho = curr_view->getHeadingOffset_deg(); +// FGViewer* curr_view = globals->get_viewmgr()->get_current_view(); +// int curr_view_id = globals->get_viewmgr()->get_current(); +// double gpo = curr_view->getGoalPitchOffset_deg(); +// double gho = curr_view->getGoalHeadingOffset_deg(); +// double po = curr_view->getPitchOffset_deg(); +// double ho = curr_view->getHeadingOffset_deg(); FGViewer* cockpitView = globals->get_viewmgr()->get_view(0); From 1223b4af9e589e721e2f7c5bb4c2f7e1821b6e89 Mon Sep 17 00:00:00 2001 From: Torsten Dreyer Date: Fri, 26 Nov 2010 19:26:12 +0100 Subject: [PATCH 4/8] Expose visibility within cloudlayers to the property-tree --- src/Environment/environment_mgr.cxx | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/src/Environment/environment_mgr.cxx b/src/Environment/environment_mgr.cxx index 5b79b25d0..7b276eb62 100644 --- a/src/Environment/environment_mgr.cxx +++ b/src/Environment/environment_mgr.cxx @@ -152,6 +152,11 @@ FGEnvironmentMgr::bind () &FGEnvironmentMgr::get_cloud_layer_coverage_type, &FGEnvironmentMgr::set_cloud_layer_coverage_type); + _tiedProperties.Tie( layerNode->getNode( "visibility-m",true), this, i, + &FGEnvironmentMgr::get_cloud_layer_visibility_m, + &FGEnvironmentMgr::set_cloud_layer_visibility_m); + + } _tiedProperties.setRoot( fgGetNode("/sim/rendering", true ) ); @@ -315,6 +320,19 @@ FGEnvironmentMgr::get_cloud_layer_coverage_type (int index) const return thesky->get_cloud_layer(index)->getCoverage(); } +double +FGEnvironmentMgr::get_cloud_layer_visibility_m (int index) const +{ + return thesky->get_cloud_layer(index)->getVisibility_m(); +} + +void +FGEnvironmentMgr::set_cloud_layer_visibility_m (int index, double visibility_m) +{ + thesky->get_cloud_layer(index)->setVisibility_m(visibility_m); +} + + void FGEnvironmentMgr::set_cloud_layer_coverage_type (int index, int type ) From f92eac7696e0bf810044cd05c0293577ca197657 Mon Sep 17 00:00:00 2001 From: Torsten Dreyer Date: Fri, 26 Nov 2010 19:27:05 +0100 Subject: [PATCH 5/8] Expose the cloud layer type to the property tree --- src/Environment/fgclouds.cxx | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/src/Environment/fgclouds.cxx b/src/Environment/fgclouds.cxx index 57d7ba42e..70f7997c4 100644 --- a/src/Environment/fgclouds.cxx +++ b/src/Environment/fgclouds.cxx @@ -279,12 +279,9 @@ void FGClouds::buildCloudLayers(void) { //double wind_speed_kt = metar_root->getDoubleValue("wind-speed-kt"); double temperature_degc = metar_root->getDoubleValue("temperature-sea-level-degc"); - double dewpoint_degc = metar_root->getDoubleValue("dewpoint-sea-level-degc"); - double pressure_mb = metar_root->getDoubleValue("pressure-sea-level-inhg") * SG_INHG_TO_PA / 100.0; - - double dewp = pow(10.0, 7.5 * dewpoint_degc / (237.7 + dewpoint_degc)); - double temp = pow(10.0, 7.5 * temperature_degc / (237.7 + temperature_degc)); - double rel_humidity = dewp * 100 / temp; + double dewpoint_degc = metar_root->getDoubleValue("dewpoint-sea-level-degc"); + double pressure_mb = metar_root->getDoubleValue("pressure-sea-level-inhg") * SG_INHG_TO_PA / 100.0; + double rel_humidity = metar_root->getDoubleValue("relative-humidity"); // formule d'Epsy, base d'un cumulus double cumulus_base = 122.0 * (temperature_degc - dewpoint_degc); @@ -295,7 +292,7 @@ void FGClouds::buildCloudLayers(void) { double alt_ft = cloud_root->getDoubleValue("elevation-ft"); double alt_m = alt_ft * SG_FEET_TO_METER; - string coverage = cloud_root->getStringValue("coverage"); + string coverage = cloud_root->getStringValue("coverage"); double coverage_norm = 0.0; if( coverage == "few" ) @@ -337,6 +334,7 @@ void FGClouds::buildCloudLayers(void) { } } + cloud_root->setStringValue("layer-type",layer_type); buildLayer(iLayer, layer_type, alt_m, coverage_norm); } } From 6403a119a29d2649d3ee9506ea0fa5bde92d1221 Mon Sep 17 00:00:00 2001 From: Torsten Dreyer Date: Fri, 26 Nov 2010 19:29:59 +0100 Subject: [PATCH 6/8] Expose the cloud layer type to the property tree Missing file --- src/Environment/environment_mgr.hxx | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/Environment/environment_mgr.hxx b/src/Environment/environment_mgr.hxx index 04758c97d..7b5ad76cb 100644 --- a/src/Environment/environment_mgr.hxx +++ b/src/Environment/environment_mgr.hxx @@ -87,6 +87,8 @@ private: void set_cloud_layer_coverage (int index, const char * coverage); int get_cloud_layer_coverage_type (int index) const; void set_cloud_layer_coverage_type (int index, int type ); + double get_cloud_layer_visibility_m (int index) const; + void set_cloud_layer_visibility_m (int index, double visibility_m); FGEnvironment * _environment; // always the same, for now FGClouds *fgClouds; From b037a80e5f11df0d316771d3a2464502a3ed1a32 Mon Sep 17 00:00:00 2001 From: ThorstenB Date: Fri, 26 Nov 2010 23:33:22 +0100 Subject: [PATCH 7/8] bug #183: Increase area where models are force-loaded before FDM release --- src/FDM/fdm_shell.cxx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/FDM/fdm_shell.cxx b/src/FDM/fdm_shell.cxx index 705776b1f..ba661e8f7 100644 --- a/src/FDM/fdm_shell.cxx +++ b/src/FDM/fdm_shell.cxx @@ -113,7 +113,7 @@ void FDMShell::update(double dt) double lon = fgGetDouble("/sim/presets/longitude-deg"); double lat = fgGetDouble("/sim/presets/latitude-deg"); - double range = 100.0; // in meters + double range = 1000.0; // in meters SGGeod geod = SGGeod::fromDeg(lon, lat); if (globals->get_scenery()->scenery_available(geod, range)) { SG_LOG(SG_FLIGHT, SG_INFO, "Scenery loaded, will init FDM"); From d438a180abea9f0864ecaf1293644ca297e0f1fe Mon Sep 17 00:00:00 2001 From: ThorstenB Date: Sat, 27 Nov 2010 20:05:28 +0100 Subject: [PATCH 8/8] Fix route manager exception and following crash (may fix #177) See bug issue #177 for more. Also fix minor compiler warning. --- src/Autopilot/route_mgr.cxx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Autopilot/route_mgr.cxx b/src/Autopilot/route_mgr.cxx index d5411b8af..c0f8f2631 100644 --- a/src/Autopilot/route_mgr.cxx +++ b/src/Autopilot/route_mgr.cxx @@ -673,7 +673,7 @@ void FGRouteMgr::insertWayptAtIndex(Waypt* aWpt, int aIndex) } int index = aIndex; - if ((aIndex == -1) || (aIndex > _route.size())) { + if ((aIndex == -1) || (aIndex > (int) _route.size())) { index = _route.size(); } @@ -1027,7 +1027,7 @@ void FGRouteMgr::jumpToIndex(int index) void FGRouteMgr::currentWaypointChanged() { - Waypt* cur = currentWaypt(); + Waypt* cur = (_currentIndexgetChild("id")->setStringValue(cur ? cur->ident() : "");