]> git.mxchange.org Git - flightgear.git/commitdiff
Durk Talsma:
authorcurt <curt>
Thu, 15 Apr 2004 22:09:46 +0000 (22:09 +0000)
committercurt <curt>
Thu, 15 Apr 2004 22:09:46 +0000 (22:09 +0000)
Enclosed you find a tar ball of the two files I changed to get the
--waypoint and --flight-plan command line option to work again.

src/Main/fg_init.cxx
src/Main/options.cxx

index 093cc19ba7f202946ac9bfee3b9a25a6a26c3629..4c3a1f1d4672eea96b60df680bf7d9fb5b3ceccd 100644 (file)
@@ -140,6 +140,7 @@ SG_USING_STD(string);
 class Sound;
 
 extern const char *default_root;
+extern string_list waypoints;
 
 #ifdef FG_USE_CLOUDS_3D
   SkySceneLoader *sgCloud3d;
@@ -900,7 +901,7 @@ static void fgSetDistOrAltFromGlideSlope() {
         fgSetDouble("/sim/presets/glideslope-deg", 0);
         fgSetBool("/sim/presets/onground", true);
     }                              
-}                       
+}
 
 
 // Set current_options lon/lat given an airport id and heading (degrees)
@@ -999,6 +1000,50 @@ static bool fgSetPosFromFix( const string& id ) {
         return false;
     }
 }
+static bool parseWaypoints()
+  {
+    vector<string>::iterator i;
+    for (i = waypoints.begin(); 
+        i  != waypoints.end();
+        i++)
+      {
+       NewWaypoint(*i);
+       // string arg = *i;
+//     string id, alt_str;
+//     double alt = 0.0;
+       
+//     string::size_type pos = arg.find( "@" );
+//     if ( pos != string::npos ) {
+//       id = arg.substr( 0, pos );
+//       alt_str = arg.substr( pos + 1 );
+//       cout << "id str = " << id << "  alt str = " << alt_str << endl;
+//       alt = atof( alt_str.c_str() );
+//       if ( !strcmp(fgGetString("/sim/startup/units"), "feet") ) {
+//         alt *= SG_FEET_TO_METER;
+//       }
+//     } else {
+//       id = arg;
+//     }
+       
+//     FGAirport a;
+//     if ( fgFindAirportID( id, &a ) ) {
+//       FGRouteMgr *rm = (FGRouteMgr *)globals->get_subsystem("route-manager");
+//       SGWayPoint wp( a.longitude, a.latitude, alt, SGWayPoint::WGS84, id );
+//       rm->add_waypoint( wp );
+         
+//       //return true;
+//     } else {
+//       return false;
+//     }
+//       }
+//     //    waypoints.begin() = waypoints.erase(waypoints.begin());
+//     return true;
+      }
+   }
+
 
 
 /**
@@ -1520,6 +1565,7 @@ bool fgInitSubsystems() {
     globals->add_subsystem( "xml-autopilot", new FGXMLAutopilot );
     globals->add_subsystem( "route-manager", new FGRouteMgr );
 
+  
     ////////////////////////////////////////////////////////////////////
     // Initialize the view manager subsystem.
     ////////////////////////////////////////////////////////////////////
@@ -1756,6 +1802,12 @@ bool fgInitSubsystems() {
     globals->add_subsystem("nasal", nasal);
     nasal->init();
 
+    ////////////////////////////////////////////////////////////////////
+    // At this point we could try and parse the waypoint options
+    ///////////////////////////////////////////////////////////////////
+    parseWaypoints();
+
+
     ////////////////////////////////////////////////////////////////////////
     // End of subsystem initialization.
     ////////////////////////////////////////////////////////////////////
index 6235939e05b952e5098bd83aa82f9bcf4a45c249..ebcbefb398eb78d78a66227a6f1356baddc4668a 100644 (file)
@@ -67,6 +67,8 @@ SG_USING_NAMESPACE(std);
 
 #define NEW_DEFAULT_MODEL_HZ 120
 
+string_list waypoints;
+
 enum
 {
     FG_OPTIONS_OK = 0,
@@ -534,36 +536,41 @@ add_channel( const string& type, const string& channel_str ) {
     return true;
 }
 
+// The parse wp and parse flight-plan options don't work anymore, because 
+// the route manager and the airport subsystems have not yet been initialized
+// at this stage. 
 
 // Parse --wp=ID[@alt]
 static bool 
 parse_wp( const string& arg ) {
-    string id, alt_str;
-    double alt = 0.0;
-
-    string::size_type pos = arg.find( "@" );
-    if ( pos != string::npos ) {
-       id = arg.substr( 0, pos );
-       alt_str = arg.substr( pos + 1 );
-       // cout << "id str = " << id << "  alt str = " << alt_str << endl;
-       alt = atof( alt_str.c_str() );
-       if ( !strcmp(fgGetString("/sim/startup/units"), "feet") ) {
-           alt *= SG_FEET_TO_METER;
-       }
-    } else {
-       id = arg;
-    }
-
-    FGAirport a;
-    if ( fgFindAirportID( id, &a ) ) {
-        FGRouteMgr *rm = (FGRouteMgr *)globals->get_subsystem("route-manager");
-       SGWayPoint wp( a.longitude, a.latitude, alt, SGWayPoint::WGS84, id );
-       rm->add_waypoint( wp );
-
-       return true;
-    } else {
-       return false;
-    }
+  //string id, alt_str;
+  //double alt = 0.0;
+  //
+  //string::size_type pos = arg.find( "@" );
+  //if ( pos != string::npos ) {
+  //id = arg.substr( 0, pos );
+  //alt_str = arg.substr( pos + 1 );
+  //// cout << "id str = " << id << "  alt str = " << alt_str << endl;
+  //alt = atof( alt_str.c_str() );
+  //if ( !strcmp(fgGetString("/sim/startup/units"), "feet") ) {
+  //    alt *= SG_FEET_TO_METER;
+  //}
+  //} else {
+  //id = arg;
+  //}
+  //
+  //FGAirport a;
+  //if ( fgFindAirportID( id, &a ) ) {
+  //    FGRouteMgr *rm = (FGRouteMgr *)globals->get_subsystem("route-manager");
+  //SGWayPoint wp( a.longitude, a.latitude, alt, SGWayPoint::WGS84, id );
+  //rm->add_waypoint( wp );
+  //
+  //return true;
+  //} else {
+  //return false;
+  //}
+  //}
+  waypoints.push_back(arg);
 }
 
 
@@ -592,7 +599,8 @@ parse_flightplan(const string& arg)
        if ( in.eof() ) {
            break;
        }
-       parse_wp(line);
+       //parse_wp(line);
+       waypoints.push_back(line);
     }
 
     return true;