]> git.mxchange.org Git - simgear.git/commitdiff
add method to delete any waypoint (last waypoint if n is out of range)
authormfranz <mfranz>
Fri, 28 Apr 2006 15:43:13 +0000 (15:43 +0000)
committermfranz <mfranz>
Fri, 28 Apr 2006 15:43:13 +0000 (15:43 +0000)
simgear/route/route.hxx

index 90265b7511c5c008d4450fe378e87e4eaa0b06f9..1eb57375a1b0f2bbd0909390844fe2c473a40294 100644 (file)
@@ -146,10 +146,16 @@ public:
     }
 
     /** Delete the front waypoint */
-    inline void delete_first() {
-       if ( route.size() ) {
-           route.erase( route.begin() );
-       }
+    inline void delete_first() { delete_waypoint(0); }
+
+    /** Delete waypoint waypoint with index n  (last one if n < 0) */
+    void delete_waypoint( int n = 0 ) {
+        if ( !route.size() )
+            return;
+        if ( n < 0 || n > (int)route.size() - 1 )
+            n = route.size() - 1;
+
+        route.erase( route.begin() + n );
     }
 
     /**