]> git.mxchange.org Git - flightgear.git/blobdiff - src/Main/options.cxx
Fix line endings
[flightgear.git] / src / Main / options.cxx
index aef5b0577cdbea4da2220b793bf4dab21d70848d..e5851a2fc17dae94916ca1883aed1a65496cc1d5 100644 (file)
@@ -2,7 +2,7 @@
 //
 // Written by Curtis Olson, started April 1998.
 //
-// Copyright (C) 1998  Curtis L. Olson  - curt@me.umn.edu
+// Copyright (C) 1998  Curtis L. Olson  - http://www.flightgear.org/~curt
 //
 // This program is free software; you can redistribute it and/or
 // modify it under the terms of the GNU General Public License as
@@ -47,7 +47,6 @@
 // #include <Airports/simple.hxx>
 // #include <Cockpit/cockpit.hxx>
 // #include <FDM/flight.hxx>
-// #include <FDM/UIUCModel/uiuc_aircraftdir.h>
 
 #include <Autopilot/route_mgr.hxx>
 #include <GUI/gui.h>
@@ -172,10 +171,16 @@ fgSetDefaults ()
     // fgSetString("/sim/startup/mouse-pointer", "disabled");
     fgSetString("/sim/control-mode", "joystick");
     fgSetBool("/sim/auto-coordination", false);
-#if !defined(WIN32)
-    fgSetString("/sim/startup/browser-app", "netscape");
-#else
+#if defined(WIN32)
     fgSetString("/sim/startup/browser-app", "webrun.bat");
+#elif defined(__APPLE__)
+    fgSetString("/sim/startup/browser-app", "open");
+#elif defined(sgi)
+    fgSetString("/sim/startup/browser-app", "launchWebJumper");
+#else
+    envp = ::getenv( "WEBBROWSER" );
+    if (!envp) envp = "netscape";
+    fgSetString("/sim/startup/browser-app", envp);
 #endif
     fgSetString("/sim/logging/priority", "alert");
 
@@ -225,14 +230,11 @@ fgSetDefaults ()
     fgSetBool("/sim/freeze/clock", false);
     fgSetBool("/sim/freeze/fuel", false);
 
-#ifdef FG_MPLAYER_AS
     fgSetString("/sim/multiplay/callsign", "callsign");
     fgSetString("/sim/multiplay/rxhost", "0");
     fgSetString("/sim/multiplay/txhost", "0");
     fgSetInt("/sim/multiplay/rxport", 0);
     fgSetInt("/sim/multiplay/txport", 0);
-#endif
-
 }
 
 static bool
@@ -597,6 +599,8 @@ clearLocation ()
     fgSetString("/sim/presets/airport-id", "");
     fgSetString("/sim/presets/vor-id", "");
     fgSetString("/sim/presets/ndb-id", "");
+    fgSetString("/sim/presets/carrier", "");
+    fgSetString("/sim/presets/parkpos", "");
     fgSetString("/sim/presets/fix", "");
 }
 
@@ -616,6 +620,21 @@ fgOptNDB( const char * arg )
     return FG_OPTIONS_OK;
 }
 
+static int
+fgOptCarrier( const char * arg )
+{
+    clearLocation();
+    fgSetString("/sim/presets/carrier", arg);
+    return FG_OPTIONS_OK;
+}
+
+static int
+fgOptParkpos( const char * arg )
+{
+    fgSetString("/sim/presets/parkpos", arg);
+    return FG_OPTIONS_OK;
+}
+
 static int
 fgOptFIX( const char * arg )
 {
@@ -1041,7 +1060,7 @@ fgOptConfig( const char *arg )
        readProperties(file, globals->get_props());
     } catch (const sg_exception &e) {
        string message = "Error loading config file: ";
-       message += e.getFormattedMessage();
+       message += e.getFormattedMessage() + e.getOrigin();
        SG_LOG(SG_INPUT, SG_ALERT, message);
        exit(2);
     }
@@ -1089,8 +1108,8 @@ fgOptNAV1( const char * arg )
 {
     double radial, freq;
     if (parse_colon(arg, &radial, &freq))
-        fgSetDouble("/radios/nav[0]/radials/selected-deg", radial);
-    fgSetDouble("/radios/nav[0]/frequencies/selected-mhz", freq);
+        fgSetDouble("/instrumentation/nav[0]/radials/selected-deg", radial);
+    fgSetDouble("/instrumentation/nav[0]/frequencies/selected-mhz", freq);
     return FG_OPTIONS_OK;
 }
 
@@ -1099,8 +1118,8 @@ fgOptNAV2( const char * arg )
 {
     double radial, freq;
     if (parse_colon(arg, &radial, &freq))
-        fgSetDouble("/radios/nav[1]/radials/selected-deg", radial);
-    fgSetDouble("/radios/nav[1]/frequencies/selected-mhz", freq);
+        fgSetDouble("/instrumentation/nav[1]/radials/selected-deg", radial);
+    fgSetDouble("/instrumentation/nav[1]/frequencies/selected-mhz", freq);
     return FG_OPTIONS_OK;
 }
 
@@ -1121,11 +1140,11 @@ fgOptDME( const char *arg )
     if (opt == "nav1") {
         fgSetInt("/instrumentation/dme/switch-position", 1);
         fgSetString("/instrumentation/dme/frequencies/source",
-                    "/radios/nav[0]/frequencies/selected-mhz");
+                    "/instrumentation/nav[0]/frequencies/selected-mhz");
     } else if (opt == "nav2") {
         fgSetInt("/instrumentation/dme/switch-position", 3);
         fgSetString("/instrumentation/dme/frequencies/source",
-                    "/radios/nav[1]/frequencies/selected-mhz");
+                    "/instrumentation/nav[1]/frequencies/selected-mhz");
     } else {
         fgSetInt("/instrumentation/dme/switch-position", 2);
         fgSetString("/instrumentation/dme/frequencies/source",
@@ -1135,6 +1154,15 @@ fgOptDME( const char *arg )
     return FG_OPTIONS_OK;
 }
 
+static int
+fgOptLivery( const char *arg )
+{
+    string opt = arg;
+    string livery_path = "livery/" + opt;
+    fgSetString("/sim/model/texture-path", livery_path.c_str() );
+    return FG_OPTIONS_OK;
+}
+
 static map<string,size_t> fgOptionMap;
 
 /*
@@ -1215,6 +1243,8 @@ struct OptionDesc {
     {"runway",                       true,  OPTION_STRING, "/sim/presets/runway", false, "", 0 },
     {"vor",                          true,  OPTION_FUNC,   "", false, "", fgOptVOR },
     {"ndb",                          true,  OPTION_FUNC,   "", false, "", fgOptNDB },
+    {"carrier",                      true,  OPTION_FUNC,   "", false, "", fgOptCarrier },
+    {"parkpos",                      true,  OPTION_FUNC,   "", false, "", fgOptParkpos },
     {"fix",                          true,  OPTION_FUNC,   "", false, "", fgOptFIX },
     {"offset-distance",              true,  OPTION_DOUBLE, "/sim/presets/offset-distance", false, "", 0 },
     {"offset-azimuth",               true,  OPTION_DOUBLE, "/sim/presets/offset-azimuth", false, "", 0 },
@@ -1258,13 +1288,14 @@ struct OptionDesc {
     {"enable-specular-highlight",    false, OPTION_BOOL,   "/sim/rendering/specular-highlight", true, "", 0 },
     {"disable-clouds",               false, OPTION_BOOL,   "/environment/clouds/status", false, "", 0 },
     {"enable-clouds",                false, OPTION_BOOL,   "/environment/clouds/status", true, "", 0 },
-#ifdef FG_USE_CLOUDS_3D
-    {"disable-clouds3d",             false, OPTION_BOOL,   "/sim/rendering/clouds3d", false, "", 0 },
-    {"enable-clouds3d",              false, OPTION_BOOL,   "/sim/rendering/clouds3d", true, "", 0 },
-#endif
+    {"disable-clouds3d",             false, OPTION_BOOL,   "/sim/rendering/clouds3d-enable", false, "", 0 },
+    {"enable-clouds3d",              false, OPTION_BOOL,   "/sim/rendering/clouds3d-enable", true, "", 0 },
     {"fov",                          true,  OPTION_FUNC,   "", false, "", fgOptFov },
+    {"aspect-ratio-multiplier",      true,  OPTION_DOUBLE, "/sim/current-view/aspect-ratio-multiplier", false, "", 0 },
     {"disable-fullscreen",           false, OPTION_BOOL,   "/sim/startup/fullscreen", false, "", 0 },
     {"enable-fullscreen",            false, OPTION_BOOL,   "/sim/startup/fullscreen", true, "", 0 },
+    {"disable-save-on-exit",         false, OPTION_BOOL,   "/sim/startup/save-on-exit", false, "", 0 },
+    {"enable-save-on-exit",          false, OPTION_BOOL,   "/sim/startup/save-on-exit", true, "", 0 },
     {"shading-flat",                 false, OPTION_BOOL,   "/sim/rendering/shading", false, "", 0 },
     {"shading-smooth",               false, OPTION_BOOL,   "/sim/rendering/shading", true, "", 0 },
     {"disable-skyblend",             false, OPTION_BOOL,   "/sim/rendering/skyblend", false, "", 0 },
@@ -1278,6 +1309,7 @@ struct OptionDesc {
     {"units-feet",                   false, OPTION_STRING, "/sim/startup/units", false, "feet", 0 },
     {"units-meters",                 false, OPTION_STRING, "/sim/startup/units", false, "meters", 0 },
     {"timeofday",                    true,  OPTION_STRING, "/sim/startup/time-offset-type", false, "noon", 0 },
+    {"season",                       true,  OPTION_STRING, "/sim/startup/season", false, "summer", 0 },
     {"time-offset",                  true,  OPTION_FUNC,   "", false, "", fgOptTimeOffset },
     {"time-match-real",              false, OPTION_STRING, "/sim/startup/time-offset-type", false, "system-offset", 0 },
     {"time-match-local",             false, OPTION_STRING, "/sim/startup/time-offset-type", false, "latitude-offset", 0 },
@@ -1308,10 +1340,8 @@ struct OptionDesc {
     {"joyclient",                    true,  OPTION_CHANNEL, "", false, "", 0 },
     {"jsclient",                     true,  OPTION_CHANNEL, "", false, "", 0 },
     {"proxy",                        true,  OPTION_FUNC,    "", false, "", fgSetupProxy },
-#ifdef FG_MPLAYER_AS
     {"callsign",                     true, OPTION_STRING,  "sim/multiplay/callsign", false, "", 0 },
     {"multiplay",                    true,  OPTION_CHANNEL, "", false, "", 0 },
-#endif
     {"trace-read",                   true,  OPTION_FUNC,   "", false, "", fgOptTraceRead },
     {"trace-write",                  true,  OPTION_FUNC,   "", false, "", fgOptTraceWrite },
     {"log-level",                    true,  OPTION_FUNC,   "", false, "", fgOptLogLevel },
@@ -1327,13 +1357,14 @@ struct OptionDesc {
     {"config",                       true,  OPTION_FUNC,   "", false, "", fgOptConfig },
     {"aircraft",                     true,  OPTION_STRING, "/sim/aircraft", false, "", 0 },
     {"failure",                      true,  OPTION_FUNC,   "", false, "", fgOptFailure },
-    {"com1",                         true,  OPTION_DOUBLE, "/radios/comm[0]/frequencies/selected-mhz", false, "", 0 },
-    {"com2",                         true,  OPTION_DOUBLE, "/radios/comm[1]/frequencies/selected-mhz", false, "", 0 },
+    {"com1",                         true,  OPTION_DOUBLE, "/instrumentation/comm[0]/frequencies/selected-mhz", false, "", 0 },
+    {"com2",                         true,  OPTION_DOUBLE, "/instrumentation/comm[1]/frequencies/selected-mhz", false, "", 0 },
     {"nav1",                         true,  OPTION_FUNC,   "", false, "", fgOptNAV1 },
     {"nav2",                         true,  OPTION_FUNC,   "", false, "", fgOptNAV2 },
     {"adf",                          true,  OPTION_FUNC,   "", false, "", fgOptADF },
     {"dme",                          true,  OPTION_FUNC,   "", false, "", fgOptDME },
     {"min-status",                   true,  OPTION_STRING,  "/sim/aircraft-min-status", false, "all", 0 },
+    {"livery",                       true,  OPTION_FUNC,   "", false, "", fgOptLivery },
     {0}
 };
 
@@ -1534,9 +1565,11 @@ fgParseOptions (const string& path) {
 #endif
 
         // catch extraneous (DOS) line ending character
-        if ( line[line.length() - 1] < 32 ) {
-            line = line.substr( 0, line.length()-1 );
-        }
+        int i;
+        for (i = line.length(); i > 0; i--)
+            if (line[i - 1] > 32)
+                break;
+        line = line.substr( 0, i );
 
        if ( parse_option( line ) == FG_OPTIONS_ERROR ) {
             cerr << endl << "Config file parse error: " << path << " '" 
@@ -1707,7 +1740,7 @@ static void fgSearchAircraft(const SGPath &path, string_list &aircraft,
    ulDirEnt* dire;
    ulDir *dirp = ulOpenDir(path.str().c_str());
    if (dirp == NULL) {
-      cerr << "Unable to open aircraft directory." << endl;
+      cerr << "Unable to open aircraft directory '" << path.str() << '\'' << endl;
       exit(-1);
    }