]> git.mxchange.org Git - flightgear.git/blobdiff - src/Main/options.cxx
Improve timing statistics
[flightgear.git] / src / Main / options.cxx
index d0662793fcf2e3dbd7b000c7275f0926fe35be38..b4a3bc830f01596d1678689f0b6c07bc48456a3e 100644 (file)
@@ -46,6 +46,7 @@
 #include <simgear/misc/sg_path.hxx>
 #include <simgear/scene/material/mat.hxx>
 #include <simgear/sound/soundmgr_openal.hxx>
+#include <simgear/misc/strutils.hxx>
 #include <Autopilot/route_mgr.hxx>
 #include <GUI/gui.h>
 
@@ -56,6 +57,7 @@
 #include "util.hxx"
 #include "viewmgr.hxx"
 #include <Main/viewer.hxx>
+#include <Environment/presets.hxx>
 
 #include <simgear/version.h>
 #include <osg/Version>
@@ -97,6 +99,8 @@ atoi( const string& str )
     return ::atoi( str.c_str() );
 }
 
+static int fgSetupProxy( const char *arg );
+
 /**
  * Set a few fail-safe default property values.
  *
@@ -244,6 +248,8 @@ fgSetDefaults ()
     fgSetString("/sim/version/revision", REVISION);
     fgSetInt("/sim/version/build-number", HUDSON_BUILD_NUMBER);
     fgSetString("/sim/version/build-id", HUDSON_BUILD_ID);
+    if( (envp = ::getenv( "http_proxy" )) != NULL )
+      fgSetupProxy( envp );
 }
 
 static bool
@@ -895,10 +901,16 @@ fgOptStartDateGmt( const char *arg )
 static int
 fgSetupProxy( const char *arg )
 {
-    string options = arg;
+    string options = simgear::strutils::strip( arg );
     string host, port, auth;
     string::size_type pos;
 
+    // this is NURLP - NURLP is not an url parser
+    if( simgear::strutils::starts_with( options, "http://" ) )
+        options = options.substr( 7 );
+    if( simgear::strutils::ends_with( options, "/" ) )
+        options = options.substr( 0, options.length() - 1 );
+
     host = port = auth = "";
     if ((pos = options.find("@")) != string::npos)
         auth = options.substr(0, pos++);
@@ -994,18 +1006,14 @@ fgOptViewOffset( const char *arg )
 static int
 fgOptVisibilityMeters( const char *arg )
 {
-    double visibility = atof( arg );
-    fgDefaultWeatherValue("visibility-m", visibility);
-    fgSetDouble("/environment/visibility-m", visibility);
+    Environment::Presets::VisibilitySingleton::instance()->preset( atof( arg ) );
     return FG_OPTIONS_OK;
 }
 
 static int
 fgOptVisibilityMiles( const char *arg )
 {
-    double visibility = atof( arg ) * 5280.0 * SG_FEET_TO_METER;
-    fgDefaultWeatherValue("visibility-m", visibility);
-    fgSetDouble("/environment/visibility-m", visibility);
+    Environment::Presets::VisibilitySingleton::instance()->preset( atof( arg ) * 5280.0 * SG_FEET_TO_METER );
     return FG_OPTIONS_OK;
 }
 
@@ -1016,7 +1024,7 @@ fgOptRandomWind( const char *arg )
     double max_hdg = min_hdg + (20 - sqrt(sg_random() * 400));
     double speed = sg_random() * sg_random() * 40;
     double gust = speed + (10 - sqrt(sg_random() * 100));
-    fgSetupWind(min_hdg, max_hdg, speed, gust);
+    Environment::Presets::WindSingleton::instance()->preset(min_hdg, max_hdg, speed, gust);
     return FG_OPTIONS_OK;
 }
 
@@ -1028,14 +1036,14 @@ fgOptWind( const char *arg )
        SG_LOG( SG_GENERAL, SG_ALERT, "bad wind value " << arg );
        return FG_OPTIONS_ERROR;
     }
-    fgSetupWind(min_hdg, max_hdg, speed, gust);
+    Environment::Presets::WindSingleton::instance()->preset(min_hdg, max_hdg, speed, gust);
     return FG_OPTIONS_OK;
 }
 
 static int
 fgOptTurbulence( const char *arg )
 {
-    fgDefaultWeatherValue("turbulence/magnitude-norm", atof(arg));
+    Environment::Presets::TurbulenceSingleton::instance()->preset( atof(arg) );
     return FG_OPTIONS_OK;
 }
 
@@ -1052,9 +1060,7 @@ fgOptCeiling( const char *arg )
         elevation = atof(spec.substr(0, pos).c_str());
         thickness = atof(spec.substr(pos + 1).c_str());
     }
-    fgSetDouble("/environment/clouds/layer[0]/elevation-ft", elevation);
-    fgSetDouble("/environment/clouds/layer[0]/thickness-ft", thickness);
-    fgSetString("/environment/clouds/layer[0]/coverage", "overcast");
+    Environment::Presets::CeilingSingleton::instance()->preset( elevation, thickness );
     return FG_OPTIONS_OK;
 }