Fix weather-related command-line options to work with the new weather
scheme.
This commit is contained in:
parent
ee806b50a1
commit
cfab836630
3 changed files with 54 additions and 10 deletions
|
@ -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 },
|
||||
|
|
|
@ -18,8 +18,13 @@
|
|||
// $Id$
|
||||
|
||||
|
||||
#include <simgear/compiler.h>
|
||||
|
||||
#include <math.h>
|
||||
|
||||
#include <vector>
|
||||
SG_USING_STD(vector);
|
||||
|
||||
#include <simgear/debug/logstream.hxx>
|
||||
|
||||
#include "fg_io.hxx"
|
||||
|
@ -32,6 +37,23 @@
|
|||
#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)
|
||||
{
|
||||
|
|
|
@ -26,6 +26,17 @@
|
|||
#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.
|
||||
*
|
||||
|
|
Loading…
Reference in a new issue