1
0
Fork 0

Fix weather-related command-line options to work with the new weather

scheme.
This commit is contained in:
david 2003-06-11 14:18:24 +00:00
parent ee806b50a1
commit cfab836630
3 changed files with 54 additions and 10 deletions

View file

@ -60,6 +60,7 @@
#include "fg_init.hxx" #include "fg_init.hxx"
#include "fg_props.hxx" #include "fg_props.hxx"
#include "options.hxx" #include "options.hxx"
#include "util.hxx"
#include "viewmgr.hxx" #include "viewmgr.hxx"
@ -208,7 +209,6 @@ fgSetDefaults ()
fgSetInt("/sim/rendering/bits-per-pixel", 16); fgSetInt("/sim/rendering/bits-per-pixel", 16);
fgSetString("/sim/view-mode", "pilot"); fgSetString("/sim/view-mode", "pilot");
fgSetDouble("/sim/current-view/heading-offset-deg", 0); fgSetDouble("/sim/current-view/heading-offset-deg", 0);
fgSetDouble("/environment/visibility-m", 20000);
// HUD options // HUD options
fgSetString("/sim/startup/units", "feet"); fgSetString("/sim/startup/units", "feet");
@ -542,12 +542,8 @@ add_channel( const string& type, const string& channel_str ) {
static void static void
setup_wind (double min_hdg, double max_hdg, double speed, double gust) setup_wind (double min_hdg, double max_hdg, double speed, double gust)
{ {
fgSetDouble("/environment/wind-from-heading-deg", min_hdg); fgDefaultWeatherValue("wind-from-heading-deg", min_hdg);
fgSetDouble("/environment/params/min-wind-from-heading-deg", min_hdg); fgDefaultWeatherValue("wind-speed-kt", speed);
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);
SG_LOG(SG_GENERAL, SG_INFO, "WIND: " << min_hdg << '@' << SG_LOG(SG_GENERAL, SG_INFO, "WIND: " << min_hdg << '@' <<
speed << " knots" << endl); speed << " knots" << endl);
@ -955,11 +951,19 @@ fgOptViewOffset( const char *arg )
return FG_OPTIONS_OK; return FG_OPTIONS_OK;
} }
static int
fgOptVisibilityMeters( const char *arg )
{
double visibility = atof( arg );
fgDefaultWeatherValue("visibility-m", visibility);
return FG_OPTIONS_OK;
}
static int static int
fgOptVisibilityMiles( const char *arg ) fgOptVisibilityMiles( const char *arg )
{ {
double visibility = atof( arg ) * 5280.0 * SG_FEET_TO_METER; double visibility = atof( arg ) * 5280.0 * SG_FEET_TO_METER;
fgSetDouble("/environment/visibility-m", visibility); fgDefaultWeatherValue("visibility-m", visibility);
return FG_OPTIONS_OK; return FG_OPTIONS_OK;
} }
@ -986,6 +990,13 @@ fgOptWind( const char *arg )
return FG_OPTIONS_OK; return FG_OPTIONS_OK;
} }
static int
fgOptTurbulence( const char *arg)
{
fgDefaultWeatherValue("turbulence-norm", atof(arg));
return FG_OPTIONS_OK;
}
static int static int
fgOptWp( const char *arg ) fgOptWp( const char *arg )
{ {
@ -1187,11 +1198,11 @@ struct OptionDesc {
{"trace-write", true, OPTION_FUNC, "", false, "", fgOptTraceWrite }, {"trace-write", true, OPTION_FUNC, "", false, "", fgOptTraceWrite },
{"log-level", true, OPTION_INT, "/sim/log-level", false, "", 0 }, {"log-level", true, OPTION_INT, "/sim/log-level", false, "", 0 },
{"view-offset", true, OPTION_FUNC, "", false, "", fgOptViewOffset }, {"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 }, {"visibility-miles", true, OPTION_FUNC, "", false, "", fgOptVisibilityMiles },
{"random-wind", false, OPTION_FUNC, "", false, "", fgOptRandomWind }, {"random-wind", false, OPTION_FUNC, "", false, "", fgOptRandomWind },
{"wind", true, OPTION_FUNC, "", false, "", fgOptWind }, {"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 }, {"wp", true, OPTION_FUNC, "", false, "", fgOptWp },
{"flight-plan", true, OPTION_FUNC, "", false, "", fgOptFlightPlan }, {"flight-plan", true, OPTION_FUNC, "", false, "", fgOptFlightPlan },
{"config", true, OPTION_FUNC, "", false, "", fgOptConfig }, {"config", true, OPTION_FUNC, "", false, "", fgOptConfig },

View file

@ -18,8 +18,13 @@
// $Id$ // $Id$
#include <simgear/compiler.h>
#include <math.h> #include <math.h>
#include <vector>
SG_USING_STD(vector);
#include <simgear/debug/logstream.hxx> #include <simgear/debug/logstream.hxx>
#include "fg_io.hxx" #include "fg_io.hxx"
@ -32,6 +37,23 @@
#endif #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 void
fgExit (int status) fgExit (int status)
{ {

View file

@ -26,6 +26,17 @@
#endif #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. * Clean up and exit FlightGear.
* *