]> git.mxchange.org Git - flightgear.git/commitdiff
Fix weather-related command-line options to work with the new weather
authordavid <david>
Wed, 11 Jun 2003 14:18:24 +0000 (14:18 +0000)
committerdavid <david>
Wed, 11 Jun 2003 14:18:24 +0000 (14:18 +0000)
scheme.

src/Main/options.cxx
src/Main/util.cxx
src/Main/util.hxx

index 2db0c79a16b72bb1867c07b4eef407261bac2401..ea9d3e51bf8148ccb845b2b70f702161bf061213 100644 (file)
@@ -60,6 +60,7 @@
 #include "fg_init.hxx"
 #include "fg_props.hxx"
 #include "options.hxx"
+#include "util.hxx"
 #include "viewmgr.hxx"
 
 
@@ -208,7 +209,6 @@ fgSetDefaults ()
     fgSetInt("/sim/rendering/bits-per-pixel", 16);
     fgSetString("/sim/view-mode", "pilot");
     fgSetDouble("/sim/current-view/heading-offset-deg", 0);
-    fgSetDouble("/environment/visibility-m", 20000);
 
                                // HUD options
     fgSetString("/sim/startup/units", "feet");
@@ -542,12 +542,8 @@ add_channel( const string& type, const string& channel_str ) {
 static void
 setup_wind (double min_hdg, double max_hdg, double speed, double gust)
 {
-  fgSetDouble("/environment/wind-from-heading-deg", min_hdg);
-  fgSetDouble("/environment/params/min-wind-from-heading-deg", min_hdg);
-  fgSetDouble("/environment/params/max-wind-from-heading-deg", max_hdg);
-  fgSetDouble("/environment/wind-speed-kt", speed);
-  fgSetDouble("/environment/params/base-wind-speed-kt", speed);
-  fgSetDouble("/environment/params/gust-wind-speed-kt", gust);
+  fgDefaultWeatherValue("wind-from-heading-deg", min_hdg);
+  fgDefaultWeatherValue("wind-speed-kt", speed);
 
   SG_LOG(SG_GENERAL, SG_INFO, "WIND: " << min_hdg << '@' << 
         speed << " knots" << endl);
@@ -955,11 +951,19 @@ fgOptViewOffset( const char *arg )
     return FG_OPTIONS_OK;
 }
 
+static int
+fgOptVisibilityMeters( const char *arg )
+{
+    double visibility = atof( arg );
+    fgDefaultWeatherValue("visibility-m", visibility);
+    return FG_OPTIONS_OK;
+}
+
 static int
 fgOptVisibilityMiles( const char *arg )
 {
     double visibility = atof( arg ) * 5280.0 * SG_FEET_TO_METER;
-    fgSetDouble("/environment/visibility-m", visibility);
+    fgDefaultWeatherValue("visibility-m", visibility);
     return FG_OPTIONS_OK;
 }
 
@@ -986,6 +990,13 @@ fgOptWind( const char *arg )
     return FG_OPTIONS_OK;
 }
 
+static int
+fgOptTurbulence( const char *arg)
+{
+    fgDefaultWeatherValue("turbulence-norm", atof(arg));
+    return FG_OPTIONS_OK;
+}
+
 static int
 fgOptWp( const char *arg )
 {
@@ -1187,11 +1198,11 @@ struct OptionDesc {
     {"trace-write",                  true,  OPTION_FUNC,   "", false, "", fgOptTraceWrite },
     {"log-level",                    true,  OPTION_INT,    "/sim/log-level", false, "", 0 },
     {"view-offset",                  true,  OPTION_FUNC,   "", false, "", fgOptViewOffset },
-    {"visibility",                   true,  OPTION_DOUBLE, "/environment/visibility-m", false, "", 0 },
+    {"visibility",                   true,  OPTION_FUNC,   "", false, "", fgOptVisibilityMeters },
     {"visibility-miles",             true,  OPTION_FUNC,   "", false, "", fgOptVisibilityMiles },
     {"random-wind",                  false, OPTION_FUNC,   "", false, "", fgOptRandomWind },
     {"wind",                         true,  OPTION_FUNC,   "", false, "", fgOptWind },
-    {"turbulence",                   true,  OPTION_DOUBLE,  "/environment/turbulence-norm", false, "", 0 },
+    {"turbulence",                   true,  OPTION_FUNC,   "", false, "", fgOptTurbulence },
     {"wp",                           true,  OPTION_FUNC,   "", false, "", fgOptWp },
     {"flight-plan",                  true,  OPTION_FUNC,   "", false, "", fgOptFlightPlan },
     {"config",                       true,  OPTION_FUNC,   "", false, "", fgOptConfig },
index 4e952685b5033e925902793a666bb3df6d16fd13..c6ab0aa5c04a63163c6df123071a2834ce9cbb9d 100644 (file)
 // $Id$
 
 
+#include <simgear/compiler.h>
+
 #include <math.h>
 
+#include <vector>
+SG_USING_STD(vector);
+
 #include <simgear/debug/logstream.hxx>
 
 #include "fg_io.hxx"
 #endif
 
 
+void
+fgDefaultWeatherValue (const char * propname, double value)
+{
+    int i;
+
+    SGPropertyNode * branch = fgGetNode("/environment/config/boundary", true);
+    vector<SGPropertyNode_ptr> entries = branch->getChildren("entry");
+    for (i = 0; i < entries.size(); i++)
+        entries[i]->setDoubleValue(propname, value);
+
+    branch = fgGetNode("/environment/config/aloft", true);
+    entries = branch->getChildren("entry");
+    for (i = 0; i < entries.size(); i++)
+        entries[i]->setDoubleValue(propname, value);
+}
+
+
 void
 fgExit (int status)
 {
index 20507033c5e4c8bda43f5efd2ac8c7feb73b9a10..093e7d69e7e78cd571a25e613e691c7a94dcd02b 100644 (file)
 #endif
 
 
+/**
+ * Initialize a single value through all existing weather levels.
+ *
+ * This function is useful mainly from the command-line.
+ *
+ * @param propname The name of the subproperty to initialized.
+ * @param value The initial value.
+ */
+extern void fgDefaultWeatherValue (const char * propname, double value);
+
+
 /**
  * Clean up and exit FlightGear.
  *