]> git.mxchange.org Git - flightgear.git/blobdiff - src/Scripting/NasalSys.cxx
Merge branch 'maint' into next
[flightgear.git] / src / Scripting / NasalSys.cxx
index 61055ce4ebb6d475facaadb89fa9f51ca94f3a6a..1941712eca92487f1ccd2b8add2ea9a9fc0cadba 100644 (file)
@@ -497,19 +497,22 @@ static naRef f_geodinfo(naContext c, naRef me, int argc, naRef* args)
 #undef HASHSET
 }
 
-class AirportInfoFilter : public FGPositioned::Filter
+class AirportInfoFilter : public FGAirport::AirportFilter
 {
 public:
   AirportInfoFilter() :
     type(FGPositioned::AIRPORT)
   { }
   
-  virtual bool pass(FGPositioned* aPos) const
-  {
-    return (aPos->type() == type);
+  virtual FGPositioned::Type minType() const {
+    return type;
   }
   
-  FGPositioned::Type type;
+  virtual FGPositioned::Type maxType() const {
+    return type;
+  }
+  
+ FGPositioned::Type type;
 };
 
 // Returns data hash for particular or nearest airport of a <type>, or nil
@@ -524,7 +527,7 @@ static naRef f_airportinfo(naContext c, naRef me, int argc, naRef* args)
     static SGConstPropertyNode_ptr latn = fgGetNode("/position/latitude-deg", true);
     static SGConstPropertyNode_ptr lonn = fgGetNode("/position/longitude-deg", true);
     SGGeod pos;
-    FGPositionedRef ref;
+    FGAirport* apt = NULL;
     
     if(argc >= 2 && naIsNum(args[0]) && naIsNum(args[1])) {
         pos = SGGeod::fromDeg(args[1].num, args[0].num);
@@ -547,8 +550,8 @@ static naRef f_airportinfo(naContext c, naRef me, int argc, naRef* args)
         else if(!strcmp(s, "heliport")) filter.type = FGPositioned::HELIPORT;
         else {
             // user provided an <id>, hopefully
-            ref = globals->get_airports()->search(s);
-            if (!ref) {
+            apt = FGAirport::findByIdent(s);
+            if (!apt) {
                 naRuntimeError(c, "airportinfo() couldn't find airport:%s", s);
                 return naNil();
             }
@@ -558,13 +561,11 @@ static naRef f_airportinfo(naContext c, naRef me, int argc, naRef* args)
         return naNil();
     }
     
-    if (!ref) {
-        ref = FGPositioned::findClosest(pos, maxRange, &filter);
+    if (!apt) {
+        apt = FGAirport::findClosest(pos, maxRange, &filter);
+        if(!apt) return naNil();
     }
     
-    if(!ref) return naNil();
-    FGAirport *apt = static_cast<FGAirport*>(ref.ptr());
-    
     string id = apt->ident();
     string name = apt->name();