]> git.mxchange.org Git - flightgear.git/blobdiff - src/Autopilot/newauto.cxx
Moved some of the low level scene graph construction code over to simgear.
[flightgear.git] / src / Autopilot / newauto.cxx
index 668811a6c9712e195c7d2c1cbdc8edd3605a74db..6762c0a30d8e5ef987cedd0d4be4f193d4211e07 100644 (file)
@@ -5,6 +5,7 @@
 // Contributions by Jeff Goeke-Smith <jgoeke@voyager.net>
 //                  Norman Vine <nhv@cape.com>
 //                  Curtis Olson <curt@flightgear.org>
+//                  Wendell Turner <wendell@adsi-m4.com>
 //
 // This program is free software; you can redistribute it and/or
 // modify it under the terms of the GNU General Public License as
@@ -44,6 +45,7 @@
 #include <Scenery/scenery.hxx>
 
 #include "newauto.hxx"
+#include "auto_gui.hxx"
 
 
 /// These statics will eventually go into the class
@@ -240,7 +242,7 @@ void FGAutopilot::init ()
     roll_out_node = fgGetNode("/autopilot/config/roll-out-deg", true);
     roll_out_smooth_node = fgGetNode("/autopilot/config/roll-out-smooth-deg", true);
 
-    current_throttle = fgGetNode("/controls/throttle");
+    current_throttle = fgGetNode("/controls/engines/engine/throttle");
 
     // initialize config properties with defaults (in case config isn't there)
     if ( TargetClimbRate->getFloatValue() < 1 )
@@ -343,10 +345,17 @@ FGAutopilot::bind ()
     fgTie("/autopilot/locks/heading", this,
          &FGAutopilot::getAPHeadingLock, &FGAutopilot::setAPHeadingLock);
     fgSetArchivable("/autopilot/locks/heading");
+
     fgTie("/autopilot/settings/heading-bug-deg", this,
          &FGAutopilot::getAPHeadingBug, &FGAutopilot::setAPHeadingBug);
     fgSetArchivable("/autopilot/settings/heading-bug-deg");
     fgSetDouble("/autopilot/settings/heading-bug-deg", 0.0f);
+
+    fgTie("/autopilot/settings/waypoint", this,
+         &FGAutopilot::getAPwaypoint, &FGAutopilot::setAPwaypoint);
+    fgSetArchivable("/autopilot/settings/waypoint");
+    fgSetString("/autopilot/settings/waypoint", "");
+
     fgTie("/autopilot/locks/wing-leveler", this,
          &FGAutopilot::getAPWingLeveler, &FGAutopilot::setAPWingLeveler);
     fgSetArchivable("/autopilot/locks/wing-leveler");
@@ -1273,6 +1282,54 @@ FGAutopilot::setAPHeadingBug (double heading)
 }
 
 
+/**
+ * return blank-separated string of waypoints
+ */
+const char *
+FGAutopilot::getAPwaypoint () const
+{
+  static char wplist[500];
+  char *p = wplist;
+  int   WPListsize, i;
+
+  // FIXME: This can cause a possible buffer overflow, EMH
+  if ( globals->get_route()->size() > 0 ) { 
+      WPListsize = globals->get_route()->size(); 
+
+      for (i = 0; i < globals->get_route()->size(); i++ ) {
+         p += sprintf(p, "%5s ",
+               globals->get_route()->get_waypoint(i).get_id().c_str() );
+      }
+      return wplist;
+
+  } else {
+    return "none specified";
+  }    
+}
+
+
+/**
+ * set next waypoint (if str='0', then delete next(first) waypoint)
+ */
+void
+FGAutopilot::setAPwaypoint (const char * apt)
+{
+  if (strcmp(apt, "0")==0)
+  {
+    SG_LOG( SG_AUTOPILOT, SG_INFO, "delete of first wp" );
+    if ( globals->get_route()->size() )
+                   globals->get_route()->delete_first();
+    return;
+  }
+
+  if ( NewWaypoint( apt ) == 0)
+    SG_LOG( SG_AUTOPILOT, SG_INFO, "Waypoint " << apt <<  "not in d.b."  );
+  else
+  {
+    /* SG_LOG( SG_AUTOPILOT, SG_INFO, "GOOD!" ); */
+  }
+}
+
 /**
  * Get the autopilot wing leveler lock (true=on).
  */