]> git.mxchange.org Git - flightgear.git/commitdiff
Tweak permitted indices for GPS route insert commands.
authorjmt <jmt>
Wed, 21 Oct 2009 07:18:36 +0000 (07:18 +0000)
committerTim Moore <timoore@redhat.com>
Wed, 21 Oct 2009 14:28:14 +0000 (16:28 +0200)
src/Instrumentation/gps.cxx

index 290dc6e4da2fbc367c5fc91ad5666948e06df626..731e8f486babc30e2538adae1e31743b1950baec 100644 (file)
@@ -1290,7 +1290,7 @@ void GPS::setCommand(const char* aCmd)
     defineWaypoint();
   } else if (!strcmp(aCmd, "route-insert-before")) {
     int index = _scratchNode->getIntValue("index");
-    if (index < 0) {
+    if (index < 0 || (_routeMgr->size() == 0)) {
       index = _routeMgr->size();
     } else if (index >= _routeMgr->size()) {
       SG_LOG(SG_INSTR, SG_WARN, "GPS:route-insert-before, bad index:" << index);
@@ -1300,7 +1300,7 @@ void GPS::setCommand(const char* aCmd)
     insertWaypointAtIndex(index);
   } else if (!strcmp(aCmd, "route-insert-after")) {
     int index = _scratchNode->getIntValue("index");
-    if (index < 0) {
+    if (index < 0 || (_routeMgr->size() == 0)) {
       index = _routeMgr->size();
     } else if (index >= _routeMgr->size()) {
       SG_LOG(SG_INSTR, SG_WARN, "GPS:route-insert-after, bad index:" << index);