]> git.mxchange.org Git - flightgear.git/blobdiff - src/Scripting/NasalSys.cxx
Expose position along the flight-path to Nasal.
[flightgear.git] / src / Scripting / NasalSys.cxx
index a3983015d753942ace0f7f2fe012a18c69fa76f4..aee1dc54d94e4b556f81d4c14fead7fa8a2d0be8 100644 (file)
@@ -13,7 +13,6 @@
 #include <sys/stat.h>
 #include <fstream>
 #include <sstream>
-#include <algorithm> // for std::sort
 
 #include <simgear/nasal/nasal.h>
 #include <simgear/props/props.hxx>
@@ -29,6 +28,7 @@
 #include "NasalPositioned.hxx"
 #include "NasalCanvas.hxx"
 #include "NasalClipboard.hxx"
+#include "NasalCondition.hxx"
 
 #include <Main/globals.hxx>
 #include <Main/util.hxx>
@@ -225,7 +225,7 @@ static naRef f_getprop(naContext c, naRef me, int argc, naRef* args)
     case props::DOUBLE:
         {
         double dv = p->getDoubleValue();
-        if (osg::isNaN(dv)) {
+        if (SGMisc<double>::isNaN(dv)) {
           SG_LOG(SG_NASAL, SG_ALERT, "Nasal getprop: property " << p->getPath() << " is NaN");
           return naNil();
         }
@@ -280,7 +280,7 @@ static naRef f_setprop(naContext c, naRef me, int argc, naRef* args)
             if(naIsNil(n))
                 naRuntimeError(c, "setprop() value is not string or number");
                 
-            if (osg::isNaN(n.num)) {
+            if (SGMisc<double>::isNaN(n.num)) {
                 naRuntimeError(c, "setprop() passed a NaN");
             }
             
@@ -557,9 +557,10 @@ void FGNasalSys::init()
     hashset(_globals, "__gcsave", _gcHash);
 
     initNasalPositioned(_globals, _context, _gcHash);
-    initNasalCanvas(_globals, _context, _gcHash);
     NasalClipboard::init(this);
-
+    initNasalCanvas(_globals, _context, _gcHash);
+    initNasalCondition(_globals, _context, _gcHash);
+  
     // Now load the various source files in the Nasal directory
     simgear::Dir nasalDir(SGPath(globals->get_fg_root(), "Nasal"));
     loadScriptDirectory(nasalDir);
@@ -633,10 +634,8 @@ bool pathSortPredicate(const SGPath& p1, const SGPath& p2)
 void FGNasalSys::loadScriptDirectory(simgear::Dir nasalDir)
 {
     simgear::PathList scripts = nasalDir.children(simgear::Dir::TYPE_FILE, ".nas");
-    // sort scripts, avoid loading sequence effects due to file system's
-    // random directory order
-    std::sort(scripts.begin(), scripts.end(), pathSortPredicate);
-
+    // Note: simgear::Dir already reports file entries in a deterministic order,
+    // so a fixed loading sequence is guaranteed (same for every user)
     for (unsigned int i=0; i<scripts.size(); ++i) {
       SGPath fullpath(scripts[i]);
       SGPath file = fullpath.file();