]> git.mxchange.org Git - flightgear.git/blobdiff - src/Scripting/NasalSys.cxx
Merge branch 'jmt/gps' into next
[flightgear.git] / src / Scripting / NasalSys.cxx
index 4fee5cfd250e8de9f7711aeec3f347074b93fffe..a210d03569c50bbafbc35ba4bda2f4720e1f9f03 100644 (file)
@@ -32,6 +32,7 @@
 #include <Main/fg_props.hxx>
 #include <Main/util.hxx>
 #include <Scenery/scenery.hxx>
+#include <Navaids/navrecord.hxx>
 
 #include "NasalSys.hxx"
 
@@ -177,25 +178,25 @@ static SGPropertyNode* findnode(naContext c, naRef* vec, int len)
 // nil if it doesn't exist.
 static naRef f_getprop(naContext c, naRef me, int argc, naRef* args)
 {
-    using namespace simgear::props;
+    using namespace simgear;
     const SGPropertyNode* p = findnode(c, args, argc);
     if(!p) return naNil();
 
     switch(p->getType()) {
-    case BOOL:   case INT:
-    case LONG:   case FLOAT:
-    case DOUBLE:
+    case props::BOOL:   case props::INT:
+    case props::LONG:   case props::FLOAT:
+    case props::DOUBLE:
         return naNum(p->getDoubleValue());
 
-    case STRING:
-    case UNSPECIFIED:
+    case props::STRING:
+    case props::UNSPECIFIED:
         {
             naRef nastr = naNewString(c);
             const char* val = p->getStringValue();
             naStr_fromdata(nastr, (char*)val, strlen(val));
             return nastr;
         }
-    case ALIAS: // <--- FIXME, recurse?
+    case props::ALIAS: // <--- FIXME, recurse?
     default:
         return naNil();
     }
@@ -414,7 +415,7 @@ static naRef f_parsexml(naContext c, naRef me, int argc, naRef* args)
 // Return UNIX epoch time in seconds.
 static naRef f_systime(naContext c, naRef me, int argc, naRef* args)
 {
-#ifdef WIN32
+#ifdef _WIN32
     FILETIME ft;
     GetSystemTimeAsFileTime(&ft);
     double t = (4294967296.0 * ft.dwHighDateTime + ft.dwLowDateTime);
@@ -555,7 +556,9 @@ static naRef f_airportinfo(naContext c, naRef me, int argc, naRef* args)
             // user provided an <id>, hopefully
             apt = FGAirport::findByIdent(s);
             if (!apt) {
-                naRuntimeError(c, "airportinfo() couldn't find airport: %s", s);
+                // return nil here, but don't raise a runtime error; this is a
+                // legitamate way to validate an ICAO code, for example in a
+                // dialog box or similar.
                 return naNil();
             }
         }
@@ -591,6 +594,11 @@ static naRef f_airportinfo(naContext c, naRef me, int argc, naRef* args)
         HASHSET("width", 5, naNum(rwy->widthM()));
         HASHSET("threshold", 9, naNum(rwy->displacedThresholdM()));
         HASHSET("stopway", 7, naNum(rwy->stopwayM()));
+        
+        if (rwy->ILS()) {
+          HASHSET("ils_frequency_mhz", 17, naNum(rwy->ILS()->get_freq() / 100.0));
+        }
+        
 #undef HASHSET
         naHash_set(rwys, rwyid, rwydata);
     }
@@ -751,7 +759,7 @@ void FGNasalSys::loadPropertyScripts()
         const char* src = n->getStringValue("script");
         if(!n->hasChild("script")) src = 0; // Hrm...
         if(src)
-            createModule(module, n->getPath(), src, strlen(src));
+            createModule(module, n->getPath().c_str(), src, strlen(src));
 
         if(!file_specified && !src)
             SG_LOG(SG_NASAL, SG_ALERT, "Nasal error: " <<
@@ -848,7 +856,7 @@ bool FGNasalSys::handleCommand(const SGPropertyNode* arg)
 {
     const char* nasal = arg->getStringValue("script");
     const char* moduleName = arg->getStringValue("module");
-    naRef code = parse(arg->getPath(true), nasal, strlen(nasal));
+    naRef code = parse(arg->getPath(true).c_str(), nasal, strlen(nasal));
     if(naIsNil(code)) return false;
 
     // Commands can be run "in" a module.  Make sure that module
@@ -1061,24 +1069,24 @@ void FGNasalListener::childRemoved(SGPropertyNode*, SGPropertyNode* child)
 
 bool FGNasalListener::changed(SGPropertyNode* node)
 {
-    using namespace simgear::props;
-    Type type = node->getType();
-    if(type == NONE) return false;
-    if(type == UNSPECIFIED) return true;
+    using namespace simgear;
+    props::Type type = node->getType();
+    if(type == props::NONE) return false;
+    if(type == props::UNSPECIFIED) return true;
 
     bool result;
     switch(type) {
-    case BOOL:
-    case INT:
-    case LONG:
+    case props::BOOL:
+    case props::INT:
+    case props::LONG:
         {
             long l = node->getLongValue();
             result = l != _last_int;
             _last_int = l;
             return result;
         }
-    case FLOAT:
-    case DOUBLE:
+    case props::FLOAT:
+    case props::DOUBLE:
         {
             double d = node->getDoubleValue();
             result = d != _last_float;