X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;ds=inline;f=src%2FMain%2Foptions.cxx;h=ad17068e682f48494c07c76a0aa5a11ab0b83697;hb=0c8c8380b1037ca52725e4703cf87ffb6aee77eb;hp=1cb754340b3b4f9ab8f20891cfa36e147e9f3eaa;hpb=6c4061bdc500d7059b71ccee3e814be6d8dddb0b;p=flightgear.git diff --git a/src/Main/options.cxx b/src/Main/options.cxx index 1cb754340..ad17068e6 100644 --- a/src/Main/options.cxx +++ b/src/Main/options.cxx @@ -35,11 +35,13 @@ #include // strcmp() #include -#include STL_STRING +#include +#include #include #include +#include #include #include #include @@ -58,11 +60,13 @@ #include "options.hxx" #include "util.hxx" #include "viewmgr.hxx" +#include
- -SG_USING_STD(string); -SG_USING_STD(sort); -SG_USING_NAMESPACE(std); +using std::string; +using std::sort; +using std::cout; +using std::cerr; +using std::endl; #ifndef VERSION #define VERSION "CVS "__DATE__ @@ -103,7 +107,7 @@ void fgSetDefaults () { // set a possibly independent location for scenery data - char *envp = ::getenv( "FG_SCENERY" ); + const char *envp = ::getenv( "FG_SCENERY" ); if ( envp != NULL ) { // fg_root could be anywhere, so default to environmental @@ -499,7 +503,7 @@ parse_fov( const string& arg ) { // // Format is "--protocol=medium,direction,hz,medium_options,..." // -// protocol = { native, nmea, garmin, AV400, fgfs, rul, pve, etc. } +// protocol = { native, nmea, garmin, AV400, AV400Sim, fgfs, rul, pve, etc. } // medium = { serial, socket, file, etc. } // direction = { in, out, bi } // hz = number of times to process channel per second (floating @@ -992,7 +996,7 @@ fgOptRandomWind( const char *arg ) static int fgOptWind( const char *arg ) { - double min_hdg, max_hdg, speed, gust; + double min_hdg = 0.0, max_hdg = 0.0, speed = 0.0, gust = 0.0; if (!parse_wind( arg, &min_hdg, &max_hdg, &speed, &gust)) { SG_LOG( SG_GENERAL, SG_ALERT, "bad wind value " << arg ); return FG_OPTIONS_ERROR; @@ -1196,6 +1200,22 @@ fgOptVersion( const char *arg ) return FG_OPTIONS_EXIT; } +static int +fgOptFpe(const char* arg) +{ + // Actually handled in bootstrap.cxx + return FG_OPTIONS_OK; +} + +static int +fgOptFgviewer(const char* arg) +{ + // Actually handled in bootstrap.cxx + return FG_OPTIONS_OK; +} + + + static map fgOptionMap; /* @@ -1216,7 +1236,7 @@ where: value set to the property if has_param is false func : function called if type==OPTION_FUNC. if has_param is true, the value is passed to the function as a string, otherwise, - 0 is passed. + s_param is passed. For OPTION_DOUBLE and OPTION_INT, the parameter value is converted into a double or an integer and set to the property. @@ -1227,12 +1247,12 @@ where: enum OptionType { OPTION_BOOL, OPTION_STRING, OPTION_DOUBLE, OPTION_INT, OPTION_CHANNEL, OPTION_FUNC }; struct OptionDesc { - char *option; + const char *option; bool has_param; enum OptionType type; - char *property; + const char *property; bool b_param; - char *s_param; + const char *s_param; int (*func)( const char * ); } fgOptionArray[] = { @@ -1248,7 +1268,8 @@ struct OptionDesc { {"disable-random-objects", false, OPTION_BOOL, "/sim/rendering/random-objects", false, "", 0 }, {"enable-random-objects", false, OPTION_BOOL, "/sim/rendering/random-objects", true, "", 0 }, {"disable-real-weather-fetch", false, OPTION_BOOL, "/environment/params/real-world-weather-fetch", false, "", 0 }, - {"enable-real-weather-fetch", false, OPTION_BOOL, "/environment/params/real-world-weather-fetch", true, "", 0 }, + {"enable-real-weather-fetch", false, OPTION_BOOL, "/environment/params/real-world-weather-fetch", true, "", 0 }, + {"metar", true, OPTION_STRING, "/environment/metar/data", false, "", 0 }, {"disable-ai-models", false, OPTION_BOOL, "/sim/ai/enabled", false, "", 0 }, {"enable-ai-models", false, OPTION_BOOL, "/sim/ai/enabled", true, "", 0 }, {"disable-freeze", false, OPTION_BOOL, "/sim/freeze/master", false, "", 0 }, @@ -1363,6 +1384,7 @@ struct OptionDesc { {"native-gui", true, OPTION_CHANNEL, "", false, "", 0 }, {"opengc", true, OPTION_CHANNEL, "", false, "", 0 }, {"AV400", true, OPTION_CHANNEL, "", false, "", 0 }, + {"AV400Sim", true, OPTION_CHANNEL, "", false, "", 0 }, {"garmin", true, OPTION_CHANNEL, "", false, "", 0 }, {"nmea", true, OPTION_CHANNEL, "", false, "", 0 }, {"generic", true, OPTION_CHANNEL, "", false, "", 0 }, @@ -1403,6 +1425,8 @@ struct OptionDesc { {"ai-scenario", true, OPTION_FUNC, "", false, "", fgOptScenario }, {"parking-id", true, OPTION_FUNC, "", false, "", fgOptParking }, {"version", false, OPTION_FUNC, "", false, "", fgOptVersion }, + {"enable-fpe", false, OPTION_FUNC, "", false, "", fgOptFpe}, + {"fgviewer", false, OPTION_FUNC, "", false, "", fgOptFgviewer}, {0} }; @@ -1544,7 +1568,7 @@ parse_option (const string& arg) if ( pt->has_param && !arg_value.empty() ) { return pt->func( arg_value.c_str() ); } else if ( !pt->has_param && arg_value.empty() ) { - return pt->func( 0 ); + return pt->func( pt->s_param ); } else if ( pt->has_param ) { SG_LOG( SG_GENERAL, SG_ALERT, "Option '" << arg << "' needs a parameter" ); return FG_OPTIONS_ERROR; @@ -1791,9 +1815,9 @@ unsigned int getNumMaturity(const char * str) { // changes should also be reflected in $FG_ROOT/data/options.xml & // $FG_ROOT/data/Translations/string-default.xml - const char levels[][20]= {"alpha","beta","early-production","production",0}; + const char* levels[] = {"alpha","beta","early-production","production"}; - for (unsigned int i=0; i<(sizeof(levels)/sizeof(levels[0])-1);i++) + for (size_t i=0; i<(sizeof(levels)/sizeof(levels[0]));i++) if (strcmp(str,levels[i])==0) return i;