]> git.mxchange.org Git - flightgear.git/blobdiff - src/Navaids/route.cxx
commradio: improvements for atis speech
[flightgear.git] / src / Navaids / route.cxx
index 952860c4d653e490690a5112ca4e40cf6a3fb416..8d4eb4029a8b04a88306adb67b928ad704ddfd97 100644 (file)
@@ -48,7 +48,7 @@
 #include <Navaids/procedure.hxx>
 #include <Navaids/waypoint.hxx>
 #include <Navaids/LevelDXML.hxx>
-#include <Airports/simple.hxx>
+#include <Airports/airport.hxx>
 
 using std::string;
 using std::vector;
@@ -91,6 +91,10 @@ bool Waypt::flag(WayptFlag aFlag) const
        
 void Waypt::setFlag(WayptFlag aFlag, bool aV)
 {
+    if (aFlag == 0) {
+        throw sg_range_exception("invalid waypoint flag set");
+    }
+    
   _flags = (_flags & ~aFlag);
   if (aV) _flags |= aFlag;
 }
@@ -237,7 +241,17 @@ WayptRef Waypt::createFromProperties(RouteBase* aOwner, SGPropertyNode_ptr aProp
       "Waypt::createFromProperties");
   }
   
-  WayptRef nd(createInstance(aOwner, aProp->getStringValue("type")));
+  try {
+    WayptRef nd(createInstance(aOwner, aProp->getStringValue("type")));
+    nd->initFromProperties(aProp);
+    return nd;
+  } catch (sg_exception& e) {
+    SG_LOG(SG_GENERAL, SG_WARN, "failed to create waypoint, trying basic:" << e.getMessage());
+  }
+  
+// if we failed to make the waypoint, try again making a basic waypoint.
+// this handles the case where a navaid waypoint is missing, for example
+  WayptRef nd(new BasicWaypt(aOwner));
   nd->initFromProperties(aProp);
   return nd;
 }